Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/docs/keep_data_small.txt
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/docs/keep_data_small.txt
r1765 r2725 60 60 61 61 One example how to reduce global data usage is in 62 archival/lib unarchive/decompress_unzip.c:62 archival/libarchive/decompress_unzip.c: 63 63 64 64 /* This is somewhat complex-looking arrangement, but it allows … … 100 100 ptr_to_globals is declared as constant pointer. 101 101 This helps gcc understand that it won't change, resulting in noticeably 102 smaller code. In order to assign it, use PTR_TO_GLOBALS macro:103 104 PTR_TO_GLOBALS = xzalloc(sizeof(G));102 smaller code. In order to assign it, use SET_PTR_TO_GLOBALS macro: 103 104 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); 105 105 106 106 Typically it is done in <applet>_main(). … … 144 144 one of above methods is not worth the resulting code obfuscation. 145 145 If you have less than ~300 bytes of global data - don't bother. 146 147 148 Finding non-shared duplicated strings 149 150 strings busybox | sort | uniq -c | sort -nr 146 151 147 152 … … 215 220 634416 2736 23856 661008 a1610 busybox 216 221 632580 2672 22944 658196 a0b14 busybox_noalign 222 223 224 225 Keeping code small 226 227 Set CONFIG_EXTRA_CFLAGS="-fno-inline-functions-called-once", 228 produce "make bloatcheck", see the biggest auto-inlined functions. 229 Now, set CONFIG_EXTRA_CFLAGS back to "", but add NOINLINE 230 to some of these functions. In 1.16.x timeframe, the results were 231 (annotated "make bloatcheck" output): 232 233 function old new delta 234 expand_vars_to_list - 1712 +1712 win 235 lzo1x_optimize - 1429 +1429 win 236 arith_apply - 1326 +1326 win 237 read_interfaces - 1163 +1163 loss, leave w/o NOINLINE 238 logdir_open - 1148 +1148 win 239 check_deps - 1148 +1148 loss 240 rewrite - 1039 +1039 win 241 run_pipe 358 1396 +1038 win 242 write_status_file - 1029 +1029 almost the same, leave w/o NOINLINE 243 dump_identity - 987 +987 win 244 mainQSort3 - 921 +921 win 245 parse_one_line - 916 +916 loss 246 summarize - 897 +897 almost the same 247 do_shm - 884 +884 win 248 cpio_o - 863 +863 win 249 subCommand - 841 +841 loss 250 receive - 834 +834 loss 251 252 855 bytes saved in total. 253 254 scripts/mkdiff_obj_bloat may be useful to automate this process: run 255 "scripts/mkdiff_obj_bloat NORMALLY_BUILT_TREE FORCED_NOINLINE_TREE" 256 and select modules which shrank.
Note:
See TracChangeset
for help on using the changeset viewer.