[OPW,kernel] scripts: Enhance bloat-o-meter to detect .rodata section size changes
diff mbox

Message ID 20141215100347.GA32070@winterfell
State New, archived
Headers show

Commit Message

Iulia Manda Dec. 15, 2014, 10:03 a.m. UTC
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.manda21@gmail.com>
---
 scripts/bloat-o-meter |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Patch
diff mbox

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])