From 965b795b87c59ed45cc7f16a62301dbae65b1627 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 30 Nov 2020 13:03:03 +0100 Subject: decrease paddign: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nilly text data bss dec hex filename 1021988 559 5052 1027599 fae0f busybox_old 1021236 559 5052 1026847 fab1f busybox_unstripped Signed-off-by: Denys Vlasenko --- libbb/capability.c | 2 +- libbb/duration.c | 2 +- libbb/hash_md5_sha.c | 22 +++++++++++----------- libbb/mode_string.c | 2 +- libbb/pw_encrypt_des.c | 15 +++++++-------- libbb/speed_table.c | 2 +- libbb/xatonum.c | 6 +++--- 7 files changed, 25 insertions(+), 26 deletions(-) (limited to 'libbb') diff --git a/libbb/capability.c b/libbb/capability.c index 23afd8eb9..e3c252a5a 100644 --- a/libbb/capability.c +++ b/libbb/capability.c @@ -17,7 +17,7 @@ extern int capget(cap_user_header_t header, const cap_user_data_t data); // This way, libcap needs not be installed in build environment. #include "libbb.h" -static const char *const capabilities[] = { +static const char *const capabilities[] ALIGN_PTR = { "chown", "dac_override", "dac_read_search", diff --git a/libbb/duration.c b/libbb/duration.c index 22b209f4d..086da15fb 100644 --- a/libbb/duration.c +++ b/libbb/duration.c @@ -21,7 +21,7 @@ #include "libbb.h" -static const struct suffix_mult duration_suffixes[] = { +static const struct suffix_mult duration_suffixes[] ALIGN_SUFFIX = { { "s", 1 }, { "m", 60 }, { "h", 60*60 }, diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index d8f210173..e0db8ce67 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c @@ -111,7 +111,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) They are defined in RFC 1321 as T[i] = (int)(2^32 * fabs(sin(i))), i=1..64 */ - static const uint32_t C_array[] = { + static const uint32_t C_array[] ALIGN4 = { /* round 1 */ 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, @@ -492,7 +492,7 @@ unsigned FAST_FUNC md5_end(md5_ctx_t *ctx, void *resbuf) static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) { - static const uint32_t rconsts[] = { + static const uint32_t rconsts[] ALIGN4 = { 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 }; int i, j; @@ -567,7 +567,7 @@ typedef uint64_t sha_K_int; typedef uint32_t sha_K_int; # define K(v) (uint32_t)(v >> 32) #endif -static const sha_K_int sha_K[] = { +static const sha_K_int sha_K[] ALIGN8 = { K(0x428a2f98d728ae22ULL), K(0x7137449123ef65cdULL), K(0xb5c0fbcfec4d3b2fULL), K(0xe9b5dba58189dbbcULL), K(0x3956c25bf348b538ULL), K(0x59f111f1b605d019ULL), @@ -760,7 +760,7 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx) ctx->process_block = sha1_process_block64; } -static const uint32_t init256[] = { +static const uint32_t init256[] ALIGN4 = { 0, 0, 0x6a09e667, @@ -773,7 +773,7 @@ static const uint32_t init256[] = { 0x5be0cd19, }; #if NEED_SHA512 -static const uint32_t init512_lo[] = { +static const uint32_t init512_lo[] ALIGN4 = { 0, 0, 0xf3bcc908, @@ -1009,7 +1009,7 @@ static void sha3_process_block72(uint64_t *state) #if OPTIMIZE_SHA3_FOR_32 /* - static const uint32_t IOTA_CONST_0[NROUNDS] = { + static const uint32_t IOTA_CONST_0[NROUNDS] ALIGN4 = { 0x00000001UL, 0x00000000UL, 0x00000000UL, @@ -1038,7 +1038,7 @@ static void sha3_process_block72(uint64_t *state) ** bits are in lsb: 0101 0000 1111 0100 1111 0001 */ uint32_t IOTA_CONST_0bits = (uint32_t)(0x0050f4f1); - static const uint32_t IOTA_CONST_1[NROUNDS] = { + static const uint32_t IOTA_CONST_1[NROUNDS] ALIGN4 = { 0x00000000UL, 0x00000089UL, 0x8000008bUL, @@ -1174,7 +1174,7 @@ static void sha3_process_block72(uint64_t *state) combine_halves(state); #else /* Native 64-bit algorithm */ - static const uint16_t IOTA_CONST[NROUNDS] = { + static const uint16_t IOTA_CONST[NROUNDS] ALIGN2 = { /* Elements should be 64-bit, but top half is always zero * or 0x80000000. We encode 63rd bits in a separate word below. * Same is true for 31th bits, which lets us use 16-bit table @@ -1210,15 +1210,15 @@ static void sha3_process_block72(uint64_t *state) /* bit for CONST[0] is in msb: 0001 0110 0011 1000 0001 1011 */ const uint32_t IOTA_CONST_bit31 = (uint32_t)(0x16381b00); - static const uint8_t ROT_CONST[24] = { + static const uint8_t ROT_CONST[24] ALIGN1 = { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44, }; - static const uint8_t PI_LANE[24] = { + static const uint8_t PI_LANE[24] ALIGN1 = { 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1, }; - /*static const uint8_t MOD5[10] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/ + /*static const uint8_t MOD5[10] ALIGN1 = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/ unsigned x; unsigned round; diff --git a/libbb/mode_string.c b/libbb/mode_string.c index 5ffd5683e..9a286f3ff 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c @@ -27,7 +27,7 @@ #define mode_t unsigned short #endif -static const mode_t mode_flags[] = { +static const mode_t mode_flags[] ALIGN4 = { S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID, S_IRGRP, S_IWGRP, S_IXGRP, S_ISGID, S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX diff --git a/libbb/pw_encrypt_des.c b/libbb/pw_encrypt_des.c index 19a9ab15b..c6fc328d8 100644 --- a/libbb/pw_encrypt_des.c +++ b/libbb/pw_encrypt_des.c @@ -65,25 +65,25 @@ /* A pile of data */ -static const uint8_t IP[64] = { +static const uint8_t IP[64] ALIGN1 = { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 }; -static const uint8_t key_perm[56] = { +static const uint8_t key_perm[56] ALIGN1 = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 }; -static const uint8_t key_shifts[16] = { +static const uint8_t key_shifts[16] ALIGN1 = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; -static const uint8_t comp_perm[48] = { +static const uint8_t comp_perm[48] ALIGN1 = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, @@ -181,13 +181,12 @@ static const uint8_t u_sbox[8][32] = { }; #endif -static const uint8_t pbox[32] = { +static const uint8_t pbox[32] ALIGN1 = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; -static const uint32_t bits32[32] = -{ +static const uint32_t bits32[32] ALIGN4 = { 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, 0x00800000, 0x00400000, 0x00200000, 0x00100000, @@ -198,7 +197,7 @@ static const uint32_t bits32[32] = 0x00000008, 0x00000004, 0x00000002, 0x00000001 }; -static const uint8_t bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; +static const uint8_t bits8[8] ALIGN1 = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; static int diff --git a/libbb/speed_table.c b/libbb/speed_table.c index 967cf8de8..cf7101e64 100644 --- a/libbb/speed_table.c +++ b/libbb/speed_table.c @@ -28,7 +28,7 @@ struct speed_map { }; /* On Linux, Bxx constants are 0..15 (up to B38400) and 0x1001..0x100f */ -static const struct speed_map speeds[] = { +static const struct speed_map speeds[] ALIGN4 = { {B0, 0}, {B50, 50}, {B75, 75}, diff --git a/libbb/xatonum.c b/libbb/xatonum.c index 7639a62aa..36b06c849 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c @@ -68,14 +68,14 @@ uint16_t FAST_FUNC xatou16(const char *numstr) return xatou_range(numstr, 0, 0xffff); } -const struct suffix_mult bkm_suffixes[] = { +const struct suffix_mult bkm_suffixes[] ALIGN_SUFFIX = { { "b", 512 }, { "k", 1024 }, { "m", 1024*1024 }, { "", 0 } }; -const struct suffix_mult cwbkMG_suffixes[] = { +const struct suffix_mult cwbkMG_suffixes[] ALIGN_SUFFIX = { { "c", 1 }, { "w", 2 }, { "b", 512 }, @@ -96,7 +96,7 @@ const struct suffix_mult cwbkMG_suffixes[] = { { "", 0 } }; -const struct suffix_mult kmg_i_suffixes[] = { +const struct suffix_mult kmg_i_suffixes[] ALIGN_SUFFIX = { { "KiB", 1024 }, { "kiB", 1024 }, { "K", 1024 }, -- cgit v1.2.3