Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: pass explicit section list to objdump #49992

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 40 additions & 14 deletions tools/genv8constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,46 @@
sys.exit(2)

outfile = open(sys.argv[1], 'w')
try:
pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
bufsize=-1, stdout=subprocess.PIPE).stdout
except OSError as e:
if e.errno == errno.ENOENT:
print('''
Node.js compile error: could not find objdump

Check that GNU binutils are installed and included in PATH
''')
else:
print('problem running objdump: ', e.strerror)

sys.exit()

def objdump(filename, opts):
try:
pipe = subprocess.Popen([ 'objdump' ] + opts + [ filename ],
bufsize=-1, stdout=subprocess.PIPE).stdout
except OSError as e:
if e.errno == errno.ENOENT:
print('''
Node.js compile error: could not find objdump

Check that GNU binutils are installed and included in PATH
''')
else:
print('problem running objdump: ', e.strerror)

sys.exit()

return pipe

# Since GNU binutils 2.41, gobjdump does not include .bss sections in
# disassembly output, even with -z.
# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=0a3137ce4c4b38ee8
# To work around this while still supporting older versions of binutils, we
# need to extract a list of sections and pass them all to objdump via -j.

sections = set()
pattern = re.compile(r'^\s+\d+\s+(\.\S+)')
pipe = objdump(sys.argv[2], [ '-h' ])
for line in pipe:
line = line.decode('utf-8')
match = pattern.match(line)
if match is None:
continue
sections.add(str(match.group(1)))

opts = [ '-z', '-D' ]
for section in sections:
opts.extend([ '-j', section ])

pipe = objdump(sys.argv[2], opts)

pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:')
v8dbg = re.compile('^v8dbg.*$')
Expand Down
Loading