3 from subprocess
import Popen
, PIPE
8 Calculate per-symbol and total size differences between obj1 and obj2,
9 which may be any files that nm can read""" % ((sys
.argv
[0],)*2)
16 proc
= Popen(args
=['nm', '-S', '-t', 'd', obj
], stdout
=PIPE
, stderr
=PIPE
)
17 out
, err
= proc
.communicate()
19 print "nm reported an error:\n"
23 for l
in out
.splitlines():
33 l
= [(k
,v
) for k
,v
in sorted(d1
.items()) if k
not in d2
]
35 print "only in %s" % obj1
36 print ''.join(" %6d %s\n" % (v
,k
) for k
,v
in l
)
37 diff
-= sum(v
for k
,v
in l
)
39 l
= [(k
,v
) for k
,v
in sorted(d2
.items()) if k
not in d1
]
41 print "only in %s" % obj2
42 print ''.join("%6d %s\n" % (v
,k
) for k
,v
in l
)
43 diff
+= sum(v
for k
,v
in l
)
45 l
= [(k
,v
,d2
[k
]) for k
,v
in sorted(d1
.items()) if k
in d2
and d2
[k
] != v
]
47 print "different sizes in %s and %s:" %(obj1
, obj2
)
48 print ''.join(" %6d %6d %s\n" % (v1
,v2
,k
) for k
,v1
,v2
in l
)
49 diff
+= sum(v2
-v1
for k
,v1
,v2
in l
)
52 print "total size difference: %+d" % diff
54 print "total size difference: 0"