*: slap on a few ALIGN* where appropriate

The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map"

function                                             old     new   delta
.rodata                                           108586  108460    -126
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126)           Total: -126 bytes
   text	   data	    bss	    dec	    hex	filename
 970412	   4219	   1848	 976479	  ee65f	busybox_old
 970286	   4219	   1848	 976353	  ee5e1	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2022-02-06 19:53:10 +01:00
parent 4f40735c87
commit ca466f385a
16 changed files with 21 additions and 20 deletions

View File

@ -36,7 +36,7 @@ int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{ {
static const char *const args[] = { static const char *const args[] ALIGN_PTR = {
"stty", "sane", NULL "stty", "sane", NULL
}; };

View File

@ -144,7 +144,7 @@ odoffset(dumper_t *dumper, int argc, char ***argvp)
} }
} }
static const char *const add_strings[] = { static const char *const add_strings[] ALIGN_PTR = {
"16/1 \"%3_u \" \"\\n\"", /* a */ "16/1 \"%3_u \" \"\\n\"", /* a */
"8/2 \" %06o \" \"\\n\"", /* B, o */ "8/2 \" %06o \" \"\\n\"", /* B, o */
"16/1 \"%03o \" \"\\n\"", /* b */ "16/1 \"%03o \" \"\\n\"", /* b */

View File

@ -346,6 +346,7 @@ typedef unsigned smalluint;
# define ALIGN4 # define ALIGN4
#endif #endif
#define ALIGN8 __attribute__((aligned(8))) #define ALIGN8 __attribute__((aligned(8)))
#define ALIGN_INT __attribute__((aligned(sizeof(int))))
#define ALIGN_PTR __attribute__((aligned(sizeof(void*)))) #define ALIGN_PTR __attribute__((aligned(sizeof(void*))))
/* /*

View File

@ -651,7 +651,7 @@ static void check_suid(int applet_no)
# if ENABLE_FEATURE_INSTALLER # if ENABLE_FEATURE_INSTALLER
static const char usr_bin [] ALIGN1 = "/usr/bin/"; static const char usr_bin [] ALIGN1 = "/usr/bin/";
static const char usr_sbin[] ALIGN1 = "/usr/sbin/"; static const char usr_sbin[] ALIGN1 = "/usr/sbin/";
static const char *const install_dir[] = { static const char *const install_dir[] ALIGN_PTR = {
&usr_bin [8], /* "/" */ &usr_bin [8], /* "/" */
&usr_bin [4], /* "/bin/" */ &usr_bin [4], /* "/bin/" */
&usr_sbin[4] /* "/sbin/" */ &usr_sbin[4] /* "/sbin/" */

View File

@ -37,7 +37,7 @@ static int open_a_console(const char *fnam)
*/ */
int FAST_FUNC get_console_fd_or_die(void) int FAST_FUNC get_console_fd_or_die(void)
{ {
static const char *const console_names[] = { static const char *const console_names[] ALIGN_PTR = {
DEV_CONSOLE, CURRENT_VC, CURRENT_TTY DEV_CONSOLE, CURRENT_VC, CURRENT_TTY
}; };

View File

@ -6011,7 +6011,7 @@ static BC_STATUS zxc_program_assign(char inst)
#endif #endif
if (ib || sc || left->t == XC_RESULT_OBASE) { if (ib || sc || left->t == XC_RESULT_OBASE) {
static const char *const msg[] = { static const char *const msg[] ALIGN_PTR = {
"bad ibase; must be [2,16]", //XC_RESULT_IBASE "bad ibase; must be [2,16]", //XC_RESULT_IBASE
"bad obase; must be [2,"BC_MAX_OBASE_STR"]", //XC_RESULT_OBASE "bad obase; must be [2,"BC_MAX_OBASE_STR"]", //XC_RESULT_OBASE
"bad scale; must be [0,"BC_MAX_SCALE_STR"]", //XC_RESULT_SCALE "bad scale; must be [0,"BC_MAX_SCALE_STR"]", //XC_RESULT_SCALE

View File

@ -303,7 +303,7 @@ int man_main(int argc UNUSED_PARAM, char **argv)
config_close(parser); config_close(parser);
if (!man_path_list) { if (!man_path_list) {
static const char *const mpl[] = { "/usr/man", "/usr/share/man", NULL }; static const char *const mpl[] ALIGN_PTR = { "/usr/man", "/usr/share/man", NULL };
man_path_list = (char**)mpl; man_path_list = (char**)mpl;
/*count_mp = 2; - not used below anyway */ /*count_mp = 2; - not used below anyway */
} }

View File

@ -532,7 +532,7 @@ static int FAST_FUNC v4tunnel_down(struct interface_defn_t * ifd, execfn * exec)
} }
# endif # endif
static const struct method_t methods6[] = { static const struct method_t methods6[] ALIGN_PTR = {
# if ENABLE_FEATURE_IFUPDOWN_IP # if ENABLE_FEATURE_IFUPDOWN_IP
{ "v4tunnel" , v4tunnel_up , v4tunnel_down , }, { "v4tunnel" , v4tunnel_up , v4tunnel_down , },
# endif # endif
@ -627,7 +627,7 @@ struct dhcp_client_t {
const char *stopcmd; const char *stopcmd;
}; };
static const struct dhcp_client_t ext_dhcp_clients[] = { static const struct dhcp_client_t ext_dhcp_clients[] ALIGN_PTR = {
{ "dhcpcd", { "dhcpcd",
"dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %client%]][[ -l %leasetime%]] %iface%", "dhcpcd[[ -h %hostname%]][[ -i %vendor%]][[ -I %client%]][[ -l %leasetime%]] %iface%",
"dhcpcd -k %iface%", "dhcpcd -k %iface%",
@ -774,7 +774,7 @@ static int FAST_FUNC wvdial_down(struct interface_defn_t *ifd, execfn *exec)
"-p /var/run/wvdial.%iface% -s 2", ifd, exec); "-p /var/run/wvdial.%iface% -s 2", ifd, exec);
} }
static const struct method_t methods[] = { static const struct method_t methods[] ALIGN_PTR = {
{ "manual" , manual_up_down, manual_up_down, }, { "manual" , manual_up_down, manual_up_down, },
{ "wvdial" , wvdial_up , wvdial_down , }, { "wvdial" , wvdial_up , wvdial_down , },
{ "ppp" , ppp_up , ppp_down , }, { "ppp" , ppp_up , ppp_down , },
@ -797,7 +797,7 @@ static int FAST_FUNC link_up_down(struct interface_defn_t *ifd UNUSED_PARAM, exe
return 1; return 1;
} }
static const struct method_t link_methods[] = { static const struct method_t link_methods[] ALIGN_PTR = {
{ "none", link_up_down, link_up_down } { "none", link_up_down, link_up_down }
}; };

View File

@ -446,13 +446,13 @@ static char *get_name(char name[IFNAMSIZ], char *p)
* %n specifiers (even the size of integers may not match). * %n specifiers (even the size of integers may not match).
*/ */
#if INT_MAX == LONG_MAX #if INT_MAX == LONG_MAX
static const char *const ss_fmt[] = { static const char *const ss_fmt[] ALIGN_PTR = {
"%n%llu%u%u%u%u%n%n%n%llu%u%u%u%u%u", "%n%llu%u%u%u%u%n%n%n%llu%u%u%u%u%u",
"%llu%llu%u%u%u%u%n%n%llu%llu%u%u%u%u%u", "%llu%llu%u%u%u%u%n%n%llu%llu%u%u%u%u%u",
"%llu%llu%u%u%u%u%u%u%llu%llu%u%u%u%u%u%u" "%llu%llu%u%u%u%u%u%u%llu%llu%u%u%u%u%u%u"
}; };
#else #else
static const char *const ss_fmt[] = { static const char *const ss_fmt[] ALIGN_PTR = {
"%n%llu%lu%lu%lu%lu%n%n%n%llu%lu%lu%lu%lu%lu", "%n%llu%lu%lu%lu%lu%n%n%n%llu%lu%lu%lu%lu%lu",
"%llu%llu%lu%lu%lu%lu%n%n%llu%llu%lu%lu%lu%lu%lu", "%llu%llu%lu%lu%lu%lu%n%n%llu%llu%lu%lu%lu%lu%lu",
"%llu%llu%lu%lu%lu%lu%lu%lu%llu%llu%lu%lu%lu%lu%lu%lu" "%llu%llu%lu%lu%lu%lu%lu%lu%llu%llu%lu%lu%lu%lu%lu%lu"
@ -731,7 +731,7 @@ static const struct hwtype ib_hwtype = {
#endif #endif
static const struct hwtype *const hwtypes[] = { static const struct hwtype *const hwtypes[] ALIGN_PTR = {
&loop_hwtype, &loop_hwtype,
&ether_hwtype, &ether_hwtype,
&ppp_hwtype, &ppp_hwtype,

View File

@ -58,7 +58,7 @@ typedef struct filter_t filter_t;
static void print_link_flags(unsigned flags, unsigned mdown) static void print_link_flags(unsigned flags, unsigned mdown)
{ {
static const int flag_masks[] = { static const int flag_masks[] ALIGN_INT = {
IFF_LOOPBACK, IFF_BROADCAST, IFF_POINTOPOINT, IFF_LOOPBACK, IFF_BROADCAST, IFF_POINTOPOINT,
IFF_MULTICAST, IFF_NOARP, IFF_UP, IFF_LOWER_UP }; IFF_MULTICAST, IFF_NOARP, IFF_UP, IFF_LOWER_UP };
static const char flag_labels[] ALIGN1 = static const char flag_labels[] ALIGN1 =

View File

@ -19,7 +19,7 @@ const uint8_t MAC_BCAST_ADDR[6] ALIGN2 = {
* See RFC2132 for more options. * See RFC2132 for more options.
* OPTION_REQ: these options are requested by udhcpc (unless -o). * OPTION_REQ: these options are requested by udhcpc (unless -o).
*/ */
const struct dhcp_optflag dhcp_optflags[] = { const struct dhcp_optflag dhcp_optflags[] ALIGN2 = {
/* flags code */ /* flags code */
{ OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */ { OPTION_IP | OPTION_REQ, 0x01 }, /* DHCP_SUBNET */
{ OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */ { OPTION_S32 , 0x02 }, /* DHCP_TIME_OFFSET */

View File

@ -65,7 +65,7 @@
/* "struct client_data_t client_data" is in bb_common_bufsiz1 */ /* "struct client_data_t client_data" is in bb_common_bufsiz1 */
static const struct dhcp_optflag d6_optflags[] = { static const struct dhcp_optflag d6_optflags[] ALIGN2 = {
#if ENABLE_FEATURE_UDHCPC6_RFC3646 #if ENABLE_FEATURE_UDHCPC6_RFC3646
{ OPTION_6RD | OPTION_LIST | OPTION_REQ, D6_OPT_DNS_SERVERS }, { OPTION_6RD | OPTION_LIST | OPTION_REQ, D6_OPT_DNS_SERVERS },
{ OPTION_DNS_STRING | OPTION_LIST | OPTION_REQ, D6_OPT_DOMAIN_LIST }, { OPTION_DNS_STRING | OPTION_LIST | OPTION_REQ, D6_OPT_DOMAIN_LIST },

View File

@ -313,7 +313,7 @@ typedef long arith_t;
/* ============ Shell options */ /* ============ Shell options */
/* If you add/change options hare, update --help text too */ /* If you add/change options hare, update --help text too */
static const char *const optletters_optnames[] = { static const char *const optletters_optnames[] ALIGN_PTR = {
"e" "errexit", "e" "errexit",
"f" "noglob", "f" "noglob",
/* bash has '-o ignoreeof', but no short synonym -I for it */ /* bash has '-o ignoreeof', but no short synonym -I for it */

View File

@ -71,7 +71,7 @@ static void bb_dump_addfile(dumper_t *dumper, char *name)
fclose(fp); fclose(fp);
} }
static const char *const add_strings[] = { static const char *const add_strings[] ALIGN_PTR = {
"\"%07.7_ax \"16/1 \"%03o \"\"\n\"", /* b */ "\"%07.7_ax \"16/1 \"%03o \"\"\n\"", /* b */
"\"%07.7_ax \"16/1 \"%3_c \"\"\n\"", /* c */ "\"%07.7_ax \"16/1 \"%3_c \"\"\n\"", /* c */
"\"%07.7_ax \"8/2 \" %05u \"\"\n\"", /* d */ "\"%07.7_ax \"8/2 \" %05u \"\"\n\"", /* d */

View File

@ -93,7 +93,7 @@ enum {
* The user namespace comes first, so that it is entered first. * The user namespace comes first, so that it is entered first.
* This gives an unprivileged user the potential to enter other namespaces. * This gives an unprivileged user the potential to enter other namespaces.
*/ */
static const struct namespace_descr ns_list[] = { static const struct namespace_descr ns_list[] ALIGN_INT = {
{ CLONE_NEWUSER, "ns/user", }, { CLONE_NEWUSER, "ns/user", },
{ CLONE_NEWIPC, "ns/ipc", }, { CLONE_NEWIPC, "ns/ipc", },
{ CLONE_NEWUTS, "ns/uts", }, { CLONE_NEWUTS, "ns/uts", },

View File

@ -120,7 +120,7 @@ enum {
NS_USR_POS, /* OPT_user, NS_USR_POS, and ns_list[] index must match! */ NS_USR_POS, /* OPT_user, NS_USR_POS, and ns_list[] index must match! */
NS_COUNT, NS_COUNT,
}; };
static const struct namespace_descr ns_list[] = { static const struct namespace_descr ns_list[] ALIGN_INT = {
{ CLONE_NEWNS, "mnt" }, { CLONE_NEWNS, "mnt" },
{ CLONE_NEWUTS, "uts" }, { CLONE_NEWUTS, "uts" },
{ CLONE_NEWIPC, "ipc" }, { CLONE_NEWIPC, "ipc" },