Skip to contentSkip to conversation

Small patch to bloat-o-meter.

PATCH In review Rob Landley 2 participants 5 messages May 7, 2006 – May 8, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Small patch to bloat-o-meter.

Workaround for the fact that gcc 4.x no longer provides consistent names for static symbols.

---

When I added bloat-o-meter to busybox, I had to fix this to get useful results. Since the kernel version seems to be the master, I thought you might be interested.

scripts/bloat-o-meter +3 -1
@@ -18,7 +18,9 @@
     for l in os.popen("nm --size-sort " + file).readlines():
         size, type, name = l[:-1].split()
         if type in "tTdDbB":
-            sym[name] = int(size, 16)
+            if name.find(".") != -1: name = "static." + name.split(".")[0]
+            if name in sym: sym[name] += int(size, 16)
+            else :sym[name] = int(size, 16)
     return sym
 
 old = getsizes(sys.argv[1])
Signature · 1 line
Never bet against the cheap plastic solution.
#1 lore raw
Quoted 13 lines · Rob Landley

Workaround for the fact that gcc 4.x no longer provides consistent names for static symbols.

---

When I added bloat-o-meter to busybox, I had to fix this to get useful results. Since the kernel version seems to be the master, I thought you might be interested.

scripts/bloat-o-meter line 21

Quoted 5 lines
scripts/bloat-o-meter +1 -1
@@ -18,7 +18,9 @@
     for l in os.popen("nm --size-sort " + file).readlines():
         size, type, name = l[:-1].split()
         if type in "tTdDbB":
-            sym[name] = int(size, 16)
+            if name.find(".") != -1: name = "static." + name.split(".")[0]

if "." in name:

(just like 'if type in "tTdDbB":' above it)

scripts/bloat-o-meter line 23

Quoted 2 lines
scripts/bloat-o-meter +2 -0
+            if name in sym: sym[name] += int(size, 16)
+            else :sym[name] = int(size, 16)

else:

Actually, this probably wants to be:

sym.setdefault(name, 0) += int(size, 16)

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#2 lore raw
Quoted 12 lines · Matt Mackall
Quoted 9 lines
scripts/bloat-o-meter +1 -2
-0400 @@ -18,7 +18,9 @@
     for l in os.popen("nm --size-sort " + file).readlines():
         size, type, name = l[:-1].split()
         if type in "tTdDbB":
-            sym[name] = int(size, 16)
+            if name.find(".") != -1: name = "static." +

name.split(".")[0]

if "." in name:

Quoted 1 line

(just like 'if type in "tTdDbB":' above it)

I learned python over 5 years ago and the language has changed out from under me a bit. When I've done a lot of C programming recently, I tend to fall back on the old ways... :)

Quoted 4 lines

scripts/bloat-o-meter line 23

Quoted 2 lines
scripts/bloat-o-meter +2 -0
+            if name in sym: sym[name] += int(size, 16)
+            else :sym[name] = int(size, 16)

else:

I'm surprised that even ran...

Quoted 3 lines

Actually, this probably wants to be:

sym.setdefault(name, 0) += int(size, 16)

File "scripts/bloat-o-meter", line 22
sym.setdefault(name, 0) += int(size, 16)
SyntaxError: can't assign to function call

Rob

Signature · 1 line
Never bet against the cheap plastic solution.
#3 lore raw
Quoted 26 lines · Rob Landley
Quoted 12 lines · Matt Mackall
Quoted 9 lines
scripts/bloat-o-meter +1 -2
-0400 @@ -18,7 +18,9 @@
     for l in os.popen("nm --size-sort " + file).readlines():
         size, type, name = l[:-1].split()
         if type in "tTdDbB":
-            sym[name] = int(size, 16)
+            if name.find(".") != -1: name = "static." +

name.split(".")[0]

if "." in name:

Quoted 1 line

(just like 'if type in "tTdDbB":' above it)

I learned python over 5 years ago and the language has changed out from under me a bit. When I've done a lot of C programming recently, I tend to fall back on the old ways... :)

Quoted 4 lines

scripts/bloat-o-meter line 23

Quoted 2 lines
scripts/bloat-o-meter +2 -0
+            if name in sym: sym[name] += int(size, 16)
+            else :sym[name] = int(size, 16)

else:

I'm surprised that even ran...

Quoted 7 lines
Quoted 3 lines

Actually, this probably wants to be:

sym.setdefault(name, 0) += int(size, 16)

File "scripts/bloat-o-meter", line 22
sym.setdefault(name, 0) += int(size, 16)
SyntaxError: can't assign to function call

Oh, right. That's why I never do that.

sym[name] = sym.get(name, 0) + int(size, 16)

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#4 lore raw

Second try: patch to upgrade scripts/bloat-o-meter to handle the names gcc 4 gives static symbols.

---

scripts/bloat-o-meter +2 -1
@@ -18,7 +18,8 @@
     for l in os.popen("nm --size-sort " + file).readlines():
         size, type, name = l[:-1].split()
         if type in "tTdDbB":
-            sym[name] = int(size, 16)
+            if "." in name: name = "static." + name.split(".")[0]
+            sym[name] = sym.get(name, 0) + int(size, 16)
     return sym
 
 old = getsizes(sys.argv[1])
Signature · 1 line
Never bet against the cheap plastic solution.