diff options
| author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-01 12:01:17 +0200 |
|---|---|---|
| committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-01 12:01:17 +0200 |
| commit | 0004e994934374b5695e004bbcb7b1fd67a170f2 (patch) | |
| tree | 6cbf7c0042fbd265b34f28111726b0f04c536818 | |
| parent | 9dc04124d5a3f0c9be249287817a964691e187b0 (diff) | |
| download | busybox-w32-0004e994934374b5695e004bbcb7b1fd67a170f2.tar.gz busybox-w32-0004e994934374b5695e004bbcb7b1fd67a170f2.tar.bz2 busybox-w32-0004e994934374b5695e004bbcb7b1fd67a170f2.zip | |
better shared strings trick
text data bss dec hex filename
861980 441 7540 869961 d4649 busybox_old
861914 441 7540 869895 d4607 busybox_unstripped
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
| -rw-r--r-- | include/libbb.h | 35 | ||||
| -rw-r--r-- | libbb/Kbuild.src | 1 | ||||
| -rw-r--r-- | libbb/inet_common.c | 6 | ||||
| -rw-r--r-- | libbb/messages.c | 9 | ||||
| -rw-r--r-- | libbb/mtab_file.c | 15 | ||||
| -rw-r--r-- | networking/ifconfig.c | 2 | ||||
| -rw-r--r-- | networking/libiproute/utils.c | 4 | ||||
| -rw-r--r-- | networking/route.c | 4 |
8 files changed, 33 insertions, 43 deletions
diff --git a/include/libbb.h b/include/libbb.h index 6fb0438f5..4b69c855f 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -1573,12 +1573,22 @@ void bb_progress_update(bb_progress_t *p, const char *curfile, | |||
| 1573 | off_t totalsize) FAST_FUNC; | 1573 | off_t totalsize) FAST_FUNC; |
| 1574 | 1574 | ||
| 1575 | extern const char *applet_name; | 1575 | extern const char *applet_name; |
| 1576 | |||
| 1577 | /* Some older linkers don't perform string merging, we used to have common strings | ||
| 1578 | * as global arrays to do it by hand. But: | ||
| 1579 | * (1) newer linkers do it themselves, | ||
| 1580 | * (2) however, they DONT merge string constants with global arrays, | ||
| 1581 | * even if the value is the same (!). Thus global arrays actually | ||
| 1582 | * increased size a bit: for example, "/etc/passwd" string from libc | ||
| 1583 | * wasn't merged with bb_path_passwd_file[] array! | ||
| 1584 | * Therefore now we use #defines. | ||
| 1585 | */ | ||
| 1576 | /* "BusyBox vN.N.N (timestamp or extra_version)" */ | 1586 | /* "BusyBox vN.N.N (timestamp or extra_version)" */ |
| 1577 | extern const char bb_banner[]; | 1587 | extern const char bb_banner[]; |
| 1578 | extern const char bb_msg_memory_exhausted[]; | 1588 | extern const char bb_msg_memory_exhausted[]; |
| 1579 | extern const char bb_msg_invalid_date[]; | 1589 | extern const char bb_msg_invalid_date[]; |
| 1580 | extern const char bb_msg_read_error[]; | 1590 | #define bb_msg_read_error "read error" |
| 1581 | extern const char bb_msg_write_error[]; | 1591 | #define bb_msg_write_error "write error" |
| 1582 | extern const char bb_msg_unknown[]; | 1592 | extern const char bb_msg_unknown[]; |
| 1583 | extern const char bb_msg_can_not_create_raw_socket[]; | 1593 | extern const char bb_msg_can_not_create_raw_socket[]; |
| 1584 | extern const char bb_msg_perm_denied_are_you_root[]; | 1594 | extern const char bb_msg_perm_denied_are_you_root[]; |
| @@ -1588,18 +1598,23 @@ extern const char bb_msg_invalid_arg[]; | |||
| 1588 | extern const char bb_msg_standard_input[]; | 1598 | extern const char bb_msg_standard_input[]; |
| 1589 | extern const char bb_msg_standard_output[]; | 1599 | extern const char bb_msg_standard_output[]; |
| 1590 | 1600 | ||
| 1591 | extern const char bb_str_default[]; | ||
| 1592 | /* NB: (bb_hexdigits_upcase[i] | 0x20) -> lowercase hex digit */ | 1601 | /* NB: (bb_hexdigits_upcase[i] | 0x20) -> lowercase hex digit */ |
| 1593 | extern const char bb_hexdigits_upcase[]; | 1602 | extern const char bb_hexdigits_upcase[]; |
| 1594 | 1603 | ||
| 1595 | extern const char bb_path_mtab_file[]; | ||
| 1596 | extern const char bb_path_passwd_file[]; | ||
| 1597 | extern const char bb_path_shadow_file[]; | ||
| 1598 | extern const char bb_path_gshadow_file[]; | ||
| 1599 | extern const char bb_path_group_file[]; | ||
| 1600 | extern const char bb_path_motd_file[]; | ||
| 1601 | extern const char bb_path_wtmp_file[]; | 1604 | extern const char bb_path_wtmp_file[]; |
| 1602 | extern const char bb_dev_null[]; | 1605 | |
| 1606 | /* Busybox mount uses either /proc/mounts or /etc/mtab to | ||
| 1607 | * get the list of currently mounted filesystems */ | ||
| 1608 | #define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts") | ||
| 1609 | |||
| 1610 | #define bb_path_passwd_file "/etc/passwd" | ||
| 1611 | #define bb_path_shadow_file "/etc/shadow" | ||
| 1612 | #define bb_path_gshadow_file "/etc/gshadow" | ||
| 1613 | #define bb_path_group_file "/etc/group" | ||
| 1614 | |||
| 1615 | #define bb_path_motd_file "/etc/motd" | ||
| 1616 | |||
| 1617 | #define bb_dev_null "/dev/null" | ||
| 1603 | extern const char bb_busybox_exec_path[]; | 1618 | extern const char bb_busybox_exec_path[]; |
| 1604 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, | 1619 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, |
| 1605 | * but I want to save a few bytes here */ | 1620 | * but I want to save a few bytes here */ |
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 5db4d8a62..b02fcfe74 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src | |||
| @@ -64,7 +64,6 @@ lib-y += md5.o | |||
| 64 | #lib-y += md5prime.o | 64 | #lib-y += md5prime.o |
| 65 | lib-y += messages.o | 65 | lib-y += messages.o |
| 66 | lib-y += mode_string.o | 66 | lib-y += mode_string.o |
| 67 | lib-y += mtab_file.o | ||
| 68 | lib-y += obscure.o | 67 | lib-y += obscure.o |
| 69 | lib-y += parse_mode.o | 68 | lib-y += parse_mode.o |
| 70 | lib-y += parse_config.o | 69 | lib-y += parse_config.o |
diff --git a/libbb/inet_common.c b/libbb/inet_common.c index b47259089..e031ddf9b 100644 --- a/libbb/inet_common.c +++ b/libbb/inet_common.c | |||
| @@ -23,7 +23,7 @@ int FAST_FUNC INET_resolve(const char *name, struct sockaddr_in *s_in, int hostf | |||
| 23 | s_in->sin_port = 0; | 23 | s_in->sin_port = 0; |
| 24 | 24 | ||
| 25 | /* Default is special, meaning 0.0.0.0. */ | 25 | /* Default is special, meaning 0.0.0.0. */ |
| 26 | if (!strcmp(name, bb_str_default)) { | 26 | if (strcmp(name, "default") == 0) { |
| 27 | s_in->sin_addr.s_addr = INADDR_ANY; | 27 | s_in->sin_addr.s_addr = INADDR_ANY; |
| 28 | return 1; | 28 | return 1; |
| 29 | } | 29 | } |
| @@ -109,7 +109,7 @@ char* FAST_FUNC INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t ne | |||
| 109 | if (ad == INADDR_ANY) { | 109 | if (ad == INADDR_ANY) { |
| 110 | if ((numeric & 0x0FFF) == 0) { | 110 | if ((numeric & 0x0FFF) == 0) { |
| 111 | if (numeric & 0x8000) | 111 | if (numeric & 0x8000) |
| 112 | return xstrdup(bb_str_default); | 112 | return xstrdup("default"); |
| 113 | return xstrdup("*"); | 113 | return xstrdup("*"); |
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| @@ -205,7 +205,7 @@ char* FAST_FUNC INET6_rresolve(struct sockaddr_in6 *sin6, int numeric) | |||
| 205 | } | 205 | } |
| 206 | if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { | 206 | if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { |
| 207 | if (numeric & 0x8000) | 207 | if (numeric & 0x8000) |
| 208 | return xstrdup(bb_str_default); | 208 | return xstrdup("default"); |
| 209 | return xstrdup("*"); | 209 | return xstrdup("*"); |
| 210 | } | 210 | } |
| 211 | 211 | ||
diff --git a/libbb/messages.c b/libbb/messages.c index 44b39942f..66e466ffa 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
| @@ -24,8 +24,6 @@ const char bb_banner[] ALIGN1 = BANNER; | |||
| 24 | 24 | ||
| 25 | const char bb_msg_memory_exhausted[] ALIGN1 = "memory exhausted"; | 25 | const char bb_msg_memory_exhausted[] ALIGN1 = "memory exhausted"; |
| 26 | const char bb_msg_invalid_date[] ALIGN1 = "invalid date '%s'"; | 26 | const char bb_msg_invalid_date[] ALIGN1 = "invalid date '%s'"; |
| 27 | const char bb_msg_write_error[] ALIGN1 = "write error"; | ||
| 28 | const char bb_msg_read_error[] ALIGN1 = "read error"; | ||
| 29 | const char bb_msg_unknown[] ALIGN1 = "(unknown)"; | 27 | const char bb_msg_unknown[] ALIGN1 = "(unknown)"; |
| 30 | const char bb_msg_can_not_create_raw_socket[] ALIGN1 = "can't create raw socket"; | 28 | const char bb_msg_can_not_create_raw_socket[] ALIGN1 = "can't create raw socket"; |
| 31 | const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied (are you root?)"; | 29 | const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied (are you root?)"; |
| @@ -35,15 +33,8 @@ const char bb_msg_invalid_arg[] ALIGN1 = "invalid argument '%s' to '%s'"; | |||
| 35 | const char bb_msg_standard_input[] ALIGN1 = "standard input"; | 33 | const char bb_msg_standard_input[] ALIGN1 = "standard input"; |
| 36 | const char bb_msg_standard_output[] ALIGN1 = "standard output"; | 34 | const char bb_msg_standard_output[] ALIGN1 = "standard output"; |
| 37 | 35 | ||
| 38 | const char bb_str_default[] ALIGN1 = "default"; | ||
| 39 | const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF"; | 36 | const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF"; |
| 40 | 37 | ||
| 41 | const char bb_path_passwd_file[] ALIGN1 = "/etc/passwd"; | ||
| 42 | const char bb_path_shadow_file[] ALIGN1 = "/etc/shadow"; | ||
| 43 | const char bb_path_group_file[] ALIGN1 = "/etc/group"; | ||
| 44 | const char bb_path_gshadow_file[] ALIGN1 = "/etc/gshadow"; | ||
| 45 | const char bb_path_motd_file[] ALIGN1 = "/etc/motd"; | ||
| 46 | const char bb_dev_null[] ALIGN1 = "/dev/null"; | ||
| 47 | const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; | 38 | const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; |
| 48 | const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; | 39 | const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; |
| 49 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, | 40 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, |
diff --git a/libbb/mtab_file.c b/libbb/mtab_file.c deleted file mode 100644 index add990ded..000000000 --- a/libbb/mtab_file.c +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | ||
| 2 | /* | ||
| 3 | * Utility routines. | ||
| 4 | * | ||
| 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
| 6 | * | ||
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include "libbb.h" | ||
| 11 | |||
| 12 | /* Busybox mount uses either /proc/mounts or /etc/mtab to | ||
| 13 | * get the list of currently mounted filesystems */ | ||
| 14 | const char bb_path_mtab_file[] ALIGN1 = | ||
| 15 | IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts"); | ||
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 853910f67..da2635ce0 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
| @@ -370,7 +370,7 @@ int ifconfig_main(int argc UNUSED_PARAM, char **argv) | |||
| 370 | #endif | 370 | #endif |
| 371 | sai.sin_family = AF_INET; | 371 | sai.sin_family = AF_INET; |
| 372 | sai.sin_port = 0; | 372 | sai.sin_port = 0; |
| 373 | if (!strcmp(host, bb_str_default)) { | 373 | if (strcmp(host, "default") == 0) { |
| 374 | /* Default is special, meaning 0.0.0.0. */ | 374 | /* Default is special, meaning 0.0.0.0. */ |
| 375 | sai.sin_addr.s_addr = INADDR_ANY; | 375 | sai.sin_addr.s_addr = INADDR_ANY; |
| 376 | } | 376 | } |
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 5125617c7..2b646f0ea 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
| @@ -64,7 +64,7 @@ int get_addr_1(inet_prefix *addr, char *name, int family) | |||
| 64 | { | 64 | { |
| 65 | memset(addr, 0, sizeof(*addr)); | 65 | memset(addr, 0, sizeof(*addr)); |
| 66 | 66 | ||
| 67 | if (strcmp(name, bb_str_default) == 0 | 67 | if (strcmp(name, "default") == 0 |
| 68 | || strcmp(name, "all") == 0 | 68 | || strcmp(name, "all") == 0 |
| 69 | || strcmp(name, "any") == 0 | 69 | || strcmp(name, "any") == 0 |
| 70 | ) { | 70 | ) { |
| @@ -103,7 +103,7 @@ static int get_prefix_1(inet_prefix *dst, char *arg, int family) | |||
| 103 | 103 | ||
| 104 | memset(dst, 0, sizeof(*dst)); | 104 | memset(dst, 0, sizeof(*dst)); |
| 105 | 105 | ||
| 106 | if (strcmp(arg, bb_str_default) == 0 | 106 | if (strcmp(arg, "default") == 0 |
| 107 | || strcmp(arg, "all") == 0 | 107 | || strcmp(arg, "all") == 0 |
| 108 | || strcmp(arg, "any") == 0 | 108 | || strcmp(arg, "any") == 0 |
| 109 | ) { | 109 | ) { |
diff --git a/networking/route.c b/networking/route.c index c72e9457f..98567aaee 100644 --- a/networking/route.c +++ b/networking/route.c | |||
| @@ -185,7 +185,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
| 185 | #endif | 185 | #endif |
| 186 | } else { | 186 | } else { |
| 187 | /* Default netmask. */ | 187 | /* Default netmask. */ |
| 188 | netmask = bb_str_default; | 188 | netmask = "default"; |
| 189 | } | 189 | } |
| 190 | /* Prefer hostname lookup is -host flag (xflag==1) was given. */ | 190 | /* Prefer hostname lookup is -host flag (xflag==1) was given. */ |
| 191 | isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, | 191 | isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, |
| @@ -346,7 +346,7 @@ static NOINLINE void INET6_setroute(int action, char **args) | |||
| 346 | /* We know args isn't NULL from the check in route_main. */ | 346 | /* We know args isn't NULL from the check in route_main. */ |
| 347 | const char *target = *args++; | 347 | const char *target = *args++; |
| 348 | 348 | ||
| 349 | if (strcmp(target, bb_str_default) == 0) { | 349 | if (strcmp(target, "default") == 0) { |
| 350 | prefix_len = 0; | 350 | prefix_len = 0; |
| 351 | memset(&sa6, 0, sizeof(sa6)); | 351 | memset(&sa6, 0, sizeof(sa6)); |
| 352 | } else { | 352 | } else { |
