Skip to content

Instantly share code, notes, and snippets.

@lpereira
Last active February 19, 2021 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpereira/2640f26e1d670d899ca80b9f3910df72 to your computer and use it in GitHub Desktop.
Save lpereira/2640f26e1d670d899ca80b9f3910df72 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import subprocess
unmappable_funcs = set()
out, err = subprocess.Popen(["objdump", "-t", "Build/Kernel/Kernel"], stdout=subprocess.PIPE).communicate()
for line in out.splitlines():
line = line.strip()
line = line.decode('ascii')
if '.unmap_after_init' in line:
func = line.split()[-1]
unmappable_funcs.add(func)
potentially_unmappable = set()
out, err = subprocess.Popen(["objdump", "-d", "Build/Kernel/Kernel"], stdout=subprocess.PIPE).communicate()
for line in out.splitlines():
in_text = False
cur_func = ''
finished_reading_text = False
for line in out.splitlines():
line = line.strip()
line = line.decode('ascii')
if 'Disassembly of section .text:' in line:
in_text = True
continue
if 'Disassembly of section ' in line:
finished_reading_text = True
break
if not in_text:
continue
if line.endswith('>:'):
cur_func = line
for symbol in unmappable_funcs:
if symbol in line:
potentially_unmappable.add(cur_func)
break
if finished_reading_text:
break
for func in potentially_unmappable:
print(func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment