dolphin/Tools/IDA/SaveDolphinMap.py
Sepalani a83858cac0 Tools: Dolphin symbol map IDA scripts added
Old ReadDolphinMap script removed
2018-05-30 09:13:12 +04:00

47 lines
1.2 KiB
Python

# Copyright 2018 Dolphin Emulator Project
# Licensed under GPLv2+
# Refer to the license.txt file included.
from collections import namedtuple
DolphinSymbol = namedtuple("DolphinSymbol", [
"section", "addr", "size", "vaddr", "align", "name"
])
def save_dolphin_map(filepath, text_map, data_map):
line = "{0.addr:08x} {0.size:08x} {0.vaddr:08x} {0.align} {0.name}\n"
with open(filepath, "w") as f:
f.write(".text section layout\n")
for symbol in text_map:
f.write(line.format(symbol))
f.write("\n.data section layout\n")
for symbol in data_map:
f.write(line.format(symbol))
def ida_main():
import idaapi
import idautils
import idc
filepath = idc.AskFile(1, "*.map", "Save a Dolphin emulator symbol map")
text_map = []
data_map = []
for ea, name in idautils.Names():
f = idaapi.get_func(ea)
if f is not None:
text_map.append(
DolphinSymbol(".text", ea, f.size(), ea, 0, name)
)
else:
data_map.append(
DolphinSymbol(".data", ea, idc.ItemSize(ea), ea, 0, name)
)
save_dolphin_map(filepath, text_map, data_map)
if __name__ == "__main__":
ida_main()