Skip to content

Commit

Permalink
tools: Add symbol_addrs.txt and export script
Browse files Browse the repository at this point in the history
  • Loading branch information
entriphy committed Feb 10, 2024
1 parent 670ecd2 commit e61dc15
Show file tree
Hide file tree
Showing 2 changed files with 8,479 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tools/ghidra/ExportToSymbolAddrs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Exports all symbols to a symbol_addrs.txt file
import os

directory = askDirectory("Select output directory", "Ok")
program = getCurrentProgram()
listing = program.getListing()
symbolTable = program.getSymbolTable()

with open(os.path.join(directory.absolutePath, "symbol_addrs.txt"), "w") as f:
for symbol in list(symbolTable.getAllSymbols(False)):
address = symbol.address.unsignedOffset
if symbol.symbolType.equals(symbol.symbolType.FUNCTION):
if symbol.name.startswith("FUN"):
continue
name = symbol.getName(address >= 0x0023A3E8)
f.write("%s = 0x%08X; // type:func\n" % (name, address))
elif symbol.symbolType.equals(symbol.symbolType.LABEL):
name = symbol.getName(False)
data = listing.getDataAt(symbol.address)
if data is None:
continue
data_type = data.getDataType()
data_size = data_type.getLength()
if data_size == -1:
continue
f.write("%s = 0x%08X; // type:symbol size:0x%X\n" % (name, address, data_size))
Loading

0 comments on commit e61dc15

Please sign in to comment.