Skip to content

Instantly share code, notes, and snippets.

@rpetrich
Created February 14, 2019 16:39
Show Gist options
  • Save rpetrich/39c25fed14a17987c27828583b93e83a to your computer and use it in GitHub Desktop.
Save rpetrich/39c25fed14a17987c27828583b93e83a to your computer and use it in GitHub Desktop.
Hopper script to import symbols that were later stripped (for example, from Symbol.map on linux kernels)
doc = Document.getCurrentDocument()
path = Document.askFile("Symbols file", None, False)
if path != None:
with open(path) as fp:
for i, line in enumerate(fp):
parts = line.split(" ")
if len(parts) > 2:
address = long(parts[0], 16)
name = parts[2]
seg = doc.getSegmentAtAddress(address)
if seg != None:
seg.setNameAtAddress(address, name.replace("\n", ""))
else:
print "No segment for 0x" + str(address) + "; unable to set name for " + name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment