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>
This commit is contained in:
Denys Vlasenko
2010-09-01 12:01:17 +02:00
parent 9dc04124d5
commit 0004e99493
8 changed files with 33 additions and 43 deletions

View File

@@ -1573,12 +1573,22 @@ void bb_progress_update(bb_progress_t *p, const char *curfile,
off_t totalsize) FAST_FUNC;
extern const char *applet_name;
/* Some older linkers don't perform string merging, we used to have common strings
* as global arrays to do it by hand. But:
* (1) newer linkers do it themselves,
* (2) however, they DONT merge string constants with global arrays,
* even if the value is the same (!). Thus global arrays actually
* increased size a bit: for example, "/etc/passwd" string from libc
* wasn't merged with bb_path_passwd_file[] array!
* Therefore now we use #defines.
*/
/* "BusyBox vN.N.N (timestamp or extra_version)" */
extern const char bb_banner[];
extern const char bb_msg_memory_exhausted[];
extern const char bb_msg_invalid_date[];
extern const char bb_msg_read_error[];
extern const char bb_msg_write_error[];
#define bb_msg_read_error "read error"
#define bb_msg_write_error "write error"
extern const char bb_msg_unknown[];
extern const char bb_msg_can_not_create_raw_socket[];
extern const char bb_msg_perm_denied_are_you_root[];
@@ -1588,18 +1598,23 @@ extern const char bb_msg_invalid_arg[];
extern const char bb_msg_standard_input[];
extern const char bb_msg_standard_output[];
extern const char bb_str_default[];
/* NB: (bb_hexdigits_upcase[i] | 0x20) -> lowercase hex digit */
extern const char bb_hexdigits_upcase[];
extern const char bb_path_mtab_file[];
extern const char bb_path_passwd_file[];
extern const char bb_path_shadow_file[];
extern const char bb_path_gshadow_file[];
extern const char bb_path_group_file[];
extern const char bb_path_motd_file[];
extern const char bb_path_wtmp_file[];
extern const char bb_dev_null[];
/* Busybox mount uses either /proc/mounts or /etc/mtab to
* get the list of currently mounted filesystems */
#define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts")
#define bb_path_passwd_file "/etc/passwd"
#define bb_path_shadow_file "/etc/shadow"
#define bb_path_gshadow_file "/etc/gshadow"
#define bb_path_group_file "/etc/group"
#define bb_path_motd_file "/etc/motd"
#define bb_dev_null "/dev/null"
extern const char bb_busybox_exec_path[];
/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
* but I want to save a few bytes here */