Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/docs/keep_data_small.txt
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/docs/keep_data_small.txt
r2725 r3621 104 104 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); 105 105 106 Typically it is done in <applet>_main(). 106 Typically it is done in <applet>_main(). Another variation is 107 to use stack: 108 109 int <applet>_main(...) 110 { 111 #undef G 112 struct globals G; 113 memset(&G, 0, sizeof(G)); 114 SET_PTR_TO_GLOBALS(&G); 107 115 108 116 Now you can reference "globals" by G.a, G.buf and so on, in any function. … … 137 145 #define dev_fd (G.dev_fd) 138 146 #define sector (G.sector) 139 140 141 Word of caution142 143 If applet doesn't use much of global data, converting it to use144 one of above methods is not worth the resulting code obfuscation.145 If you have less than ~300 bytes of global data - don't bother.146 147 147 148 … … 224 225 225 226 Keeping code small 227 228 Use scripts/bloat-o-meter to check whether introduced changes 229 didn't generate unnecessary bloat. This script needs unstripped binaries 230 to generate a detailed report. To automate this, just use 231 "make bloatcheck". It requires busybox_old binary to be present, 232 use "make baseline" to generate it from unmodified source, or 233 copy busybox_unstripped to busybox_old before modifying sources 234 and rebuilding. 226 235 227 236 Set CONFIG_EXTRA_CFLAGS="-fno-inline-functions-called-once",
Note:
See TracChangeset
for help on using the changeset viewer.