Created
August 31, 2011 10:53
-
-
Save fritschy/1183292 to your computer and use it in GitHub Desktop.
Sort objdump -d ouput by function name (useful for text compares).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, re | |
infunction=False | |
currfunc="" | |
funclines=[] | |
functions={} | |
for line in sys.stdin: | |
line=line.rstrip() | |
if len(line) == 0: | |
if infunction: | |
infunction=False | |
functions[currfunc[0]] = (currfunc[1], "\n".join(funclines)) | |
funclines=[] | |
else: | |
continue | |
if infunction: | |
try: | |
addr,code=map(str.lstrip, line.split(':', 1)) | |
except: | |
pass | |
funclines.append(code) | |
continue | |
if re.match(r"^[0-9a-fA-F]+ .*$", line): | |
addr,name=line.split(' ', 1) | |
name=name.rstrip(':').lstrip('<').rstrip('>') | |
currfunc=(name, addr) | |
infunction=True | |
print('Found %d functions' % len(functions)) | |
function_names=functions.keys() | |
function_names.sort() | |
for i in function_names: | |
print('%s %s' % (functions[i][0], i)) | |
print(functions[i][1]) | |
print(' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment