retdec
retdec copied to clipboard
Can I supply symbol information?
Hi,
My image is bytecode extracted from a video game ROM, which uses global variables with fixed memory addresses and has known C structs.
If possible, I would like to add my own symbol information so the resulting C file is more readable. Specifically, I would like to:
- Define a map of memory addresses and function names, so retdec can name my functions according to my list rather than
function_<address>
. - Define the known C structs that are used in the program.
- Define a map of memory addresses and variable types & names (eg. variable at address
X
is astruct foo
namedbar
).
I think PDB files might be what I'm after, but it looks like that's a proprietary format and only used for Windows executables.
Is this something that I can do with retdec, or do I need to apply my own post processing on retdec's generated C file?
You could convert it to an ELF, load it in IDA Pro and use the dwarf exporter plugin.
@PeterMatula Can you please provide an answer? I would provide an answer on my own, but yours would probably be better in this case.
I'd find this extremely useful too, to go alongside the M68K support I'm working on adding.
M68K is widely used in embedded systems and a good decompiler with memory-map and I/O mapping support would be a game-changer for several platforms (NeoGeo, Sega Genesis/Megadrive, Amiga, Atari ST...)
I added this to a new milestone, since we would like to improve a RetDec <-> {IDA, r2, users}
interactions by the end of the summer and this issue is related to it.
The current state regarding your points:
- It is possible to give RetDec a JSON file with information about functions. It then should be used to name them. This mechanism is use in retdec-idaplugin. It is not documented and tested outside the plugin. We will write some plugin-independent tests to make sure it works and create a wiki page tutorial.
- Related to #578. The JSON also allows you to define structures, but it is not very convenient and it does not work very well. This will need more work, but we would like to improve it by the end of the summer.
- Again, you can define globals in JSON, just like functions, but giving them structured types will not work very well.
We will work on better IDA and r2 integration over the summer, and this should get solved alongside it.
I'm interested in this too and was trying to read through the ida plugin to understand how it works. I was trying to edit the json file that is output to correct function signatures but the next run just overwrote it. Is there a way the plugin tells the next pass to trust the info?
I'm happy to help write converters to the json format once it's clear how to get it used by retdec. Thanks!
It'd be nice if retdec could import map-files which are already existing de-facto standard for tools.