Last active
December 29, 2020 02:58
-
-
Save d4l3k/7b4342bc1c9beff9881f9409abe090e8 to your computer and use it in GitHub Desktop.
Ghidra script to load kallsyms as labels
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
# load a kallsyms table | |
#@author d4l3k | |
#@category kernelscripts | |
USER_DEFINED = ghidra.program.model.symbol.SourceType.USER_DEFINED | |
baseAddress = currentProgram.getImageBase() | |
print("base address", baseAddress) | |
def set_name(addr, name): | |
name = name.replace(' ', '-') | |
createLabel(addr, name, True, USER_DEFINED) | |
f = askFile("kallsyms", "Open") | |
for line in open(f.absolutePath, 'rb').readlines(): | |
addr_str, _, name = line.strip().split(" ") | |
addr_long = long(addr_str, 16) | |
print(addr_long, name) | |
addr = toAddr(addr_str) | |
set_name(addr, name) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment