Skip to content

Instantly share code, notes, and snippets.

@psifertex
Created August 5, 2022 20:41
Show Gist options
  • Save psifertex/cda157f7d5eb3caa233b16dddd30f6ad to your computer and use it in GitHub Desktop.
Save psifertex/cda157f7d5eb3caa233b16dddd30f6ad to your computer and use it in GitHub Desktop.
# Untested, but could be used to generate a script to annotate a binary for GDB
# Run this script inside of the snippet editor to create a shell script
output = "#!/bin/bash\n"
for sym in bv.get_symbols():
flags = ",global"
if sym.type == SymbolType.FunctionSymbol:
flags += ",function"
output += f"objcopy input --add-symbol {sym.name}=.text:{hex(sym.address)}{flags} output; mv output input;\n"
outputfile = get_save_filename_input("script command")
if outputfile:
with open(outputfile, "w", encoding="utf-8") as f:
f.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment