Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 28a2094

Browse files
brglDenys Vlasenko
authored and
Denys Vlasenko
committedOct 16, 2013
bloat-o-meter: add usage info
Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Denys Vlasenko <[email protected]>
1 parent 6493801 commit 28a2094

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed
 

‎docs/keep_data_small.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,6 @@ less readable, use #defines:
138138
#define sector (G.sector)
139139

140140

141-
Word of caution
142-
143-
If applet doesn't use much of global data, converting it to use
144-
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-
148141
Finding non-shared duplicated strings
149142

150143
strings busybox | sort | uniq -c | sort -nr
@@ -224,6 +217,14 @@ Result (non-static busybox built against glibc):
224217

225218
Keeping code small
226219

220+
Use scripts/bloat-o-meter to check whether introduced changes
221+
didn't generate unnecessary bloat. This script needs unstripped binaries
222+
to generate a detailed report. To automate this, just use
223+
"make bloatcheck". It requires busybox_old binary to be present,
224+
use "make baseline" to generate it from unmodified source, or
225+
copy busybox_unstripped to busybox_old before modifying sources
226+
and rebuilding.
227+
227228
Set CONFIG_EXTRA_CFLAGS="-fno-inline-functions-called-once",
228229
produce "make bloatcheck", see the biggest auto-inlined functions.
229230
Now, set CONFIG_EXTRA_CFLAGS back to "", but add NOINLINE

‎scripts/bloat-o-meter

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
# This software may be used and distributed according to the terms
88
# of the GNU General Public License, incorporated herein by reference.
99

10-
import sys, os#, re
10+
import sys, os
1111

1212
def usage():
13-
sys.stderr.write("usage: %s [-t] file1 file2\n" % sys.argv[0])
14-
sys.exit(-1)
13+
sys.stderr.write("usage: %s [-t] file1 file2 [-- <readelf options>]\n"
14+
% sys.argv[0])
15+
sys.stderr.write("\t-t\tShow time spent on parsing/processing\n")
16+
sys.stderr.write("\t--\tPass additional parameters to readelf\n")
17+
sys.exit(1)
1518

1619
f1, f2 = (None, None)
1720
flag_timing, dashes = (False, False)
@@ -31,6 +34,8 @@ for f in sys.argv[1:]:
3134
f1 = f
3235
elif f2 is None:
3336
f2 = f
37+
else:
38+
usage()
3439
if flag_timing:
3540
import time
3641
if f1 is None or f2 is None:

0 commit comments

Comments
 (0)
Please sign in to comment.