diff options
author | Ron Yorston <rmy@pobox.com> | 2021-03-08 19:30:57 +0000 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-03-09 17:25:07 +0100 |
commit | 0b25e810ed73334d30f99ba7073f21369b33ab18 (patch) | |
tree | 8dc62de8a1038cc5e52471198aae621bcce59ba5 | |
parent | 307cd26e9893ed0cf6ee88e7fca2d61d3da0e139 (diff) | |
download | busybox-w32-0b25e810ed73334d30f99ba7073f21369b33ab18.tar.gz busybox-w32-0b25e810ed73334d30f99ba7073f21369b33ab18.tar.bz2 busybox-w32-0b25e810ed73334d30f99ba7073f21369b33ab18.zip |
bloat-o-meter: avoid double counting
Disable 'echo' in the default config, run 'make baseline', then
re-enable 'echo' and run 'make bloatcheck':
function old new delta
.rodata 182521 182622 +101
packed_usage 33714 33792 +78
applet_main 3168 3176 +8
applet_names 2730 2735 +5
applet_suid 99 100 +1
applet_install_loc 198 199 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 194/0) Total: 194 bytes
text data bss dec hex filename
955052 4195 1808 961055 eaa1f busybox_old
955153 4195 1808 961156 eaa84 busybox_unstripped
The Total bytes value doesn't equal the change in the size of the
binary. The packed_usage and applet_* items are in .rodata and
are counted twice. With this modified bloat-o-meter the size of
named items is deducted from .rodata:
function old new delta
packed_usage 33714 33792 +78
applet_main 3168 3176 +8
.rodata 105105 105113 +8
applet_names 2730 2735 +5
applet_suid 99 100 +1
applet_install_loc 198 199 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 101/0) Total: 101 bytes
text data bss dec hex filename
955052 4195 1808 961055 eaa1f busybox_old
955153 4195 1808 961156 eaa84 busybox_unstripped
v2: Sections numbered less than 10 were always being omitted from
consideration because splitting "[ 1] .interp" leaves "1]" in
x[1] where the section name is expected. This wasn't a problem
for .rodata (numbered 15 in my testing) but let's fix it anyway.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-x | scripts/bloat-o-meter | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter index cb861b8e9..b4a1d2811 100755 --- a/scripts/bloat-o-meter +++ b/scripts/bloat-o-meter | |||
@@ -43,7 +43,15 @@ if f1 is None or f2 is None: | |||
43 | 43 | ||
44 | sym_args = " ".join(sys.argv[3 + flag_timing + dashes:]) | 44 | sym_args = " ".join(sys.argv[3 + flag_timing + dashes:]) |
45 | def getsizes(file): | 45 | def getsizes(file): |
46 | sym, alias, lut = {}, {}, {} | 46 | sym, alias, lut, section = {}, {}, {}, {} |
47 | for l in os.popen("readelf -W -S " + file).readlines(): | ||
48 | x = l.replace("[ ", "[", 1).split() | ||
49 | if len(x)<6: continue | ||
50 | # Should take these into account too! | ||
51 | #if x[1] not in [".text", ".rodata", ".symtab", ".strtab"]: continue | ||
52 | if x[1] not in [".rodata"]: continue | ||
53 | sym[x[1]] = {"addr" : int(x[3], 16), "size" : int(x[5], 16)} | ||
54 | section[x[0][1:-1]] = {"name" : x[1]} | ||
47 | for l in os.popen("readelf -W -s %s %s" % (sym_args, file)).readlines(): | 55 | for l in os.popen("readelf -W -s %s %s" % (sym_args, file)).readlines(): |
48 | l = l.strip() | 56 | l = l.strip() |
49 | if not (len(l) and l[0].isdigit() and len(l.split()) == 8): | 57 | if not (len(l) and l[0].isdigit() and len(l.split()) == 8): |
@@ -59,6 +67,10 @@ def getsizes(file): | |||
59 | else: | 67 | else: |
60 | sym[name] = {"addr" : value, "size": size} | 68 | sym[name] = {"addr" : value, "size": size} |
61 | lut[(value, size)] = 0 | 69 | lut[(value, size)] = 0 |
70 | # If this item is in a known section deduct its size from | ||
71 | # the size of the section | ||
72 | if ndx in section: | ||
73 | sym[section[ndx]["name"]]["size"] -= size | ||
62 | for addr, sz in iter(alias.keys()): | 74 | for addr, sz in iter(alias.keys()): |
63 | # If the non-GLOBAL sym has an implementation elsewhere then | 75 | # If the non-GLOBAL sym has an implementation elsewhere then |
64 | # it's an alias, disregard it. | 76 | # it's an alias, disregard it. |
@@ -66,13 +78,6 @@ def getsizes(file): | |||
66 | # If this non-GLOBAL sym does not have an implementation at | 78 | # If this non-GLOBAL sym does not have an implementation at |
67 | # another address, then treat it as a normal symbol. | 79 | # another address, then treat it as a normal symbol. |
68 | sym[alias[(addr, sz)]["name"]] = {"addr" : addr, "size": sz} | 80 | sym[alias[(addr, sz)]["name"]] = {"addr" : addr, "size": sz} |
69 | for l in os.popen("readelf -W -S " + file).readlines(): | ||
70 | x = l.split() | ||
71 | if len(x)<6: continue | ||
72 | # Should take these into account too! | ||
73 | #if x[1] not in [".text", ".rodata", ".symtab", ".strtab"]: continue | ||
74 | if x[1] not in [".rodata"]: continue | ||
75 | sym[x[1]] = {"addr" : int(x[3], 16), "size" : int(x[5], 16)} | ||
76 | return sym | 81 | return sym |
77 | 82 | ||
78 | if flag_timing: | 83 | if flag_timing: |