[PATCH] scripts: Enhance bloat-o-meter to detect .rodata section size changes

13 views
Skip to first unread message

Iulia Manda

unread,
Dec 15, 2014, 5:04:27 AM12/15/14
to jo...@joshtriplett.org, opw-k...@googlegroups.com, fir...@lists.rosedu.org
Add functionality to scripts/bloat-o-meter to detect size changes in *.rodata*
sections not associated with a symbol (e.g changes to string constants).

Please note that gcc uses string padding, so .rodata section size may not change
after a small addition/removal.

Signed-off-by: Iulia Manda <iulia....@gmail.com>
---
scripts/bloat-o-meter | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index 23e78dc..71bbf1b 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -7,7 +7,7 @@
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

-import sys, os, re
+import sys, os, re, subprocess

if len(sys.argv) != 3:
sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
@@ -26,6 +26,17 @@ def getsizes(file):
# statics and some other optimizations adds random .NUMBER
name = re.sub(r'\.[0-9]+', '', name)
sym[name] = sym.get(name, 0) + int(size, 16)
+
+ for k in os.popen("objdump -h " + file).readlines():
+ s = k.split()
+ # retain Size column index
+ if "Size" in k:
+ idx = s.index("Size")
+ # cumulate all *rodata* sections' sizes
+ if ".rodata" in k:
+ if ".rodata" not in sym:
+ sym[".rodata"] = 0
+ sym[".rodata"] += int(s[idx], 16)
return sym

old = getsizes(sys.argv[1])
--
1.7.10.4

Reply all
Reply to author
Forward
0 new messages