Reputation: 13
I have a .out eabi binary file and I'm trying to parse out all the symbol names, addresses, types, and byte sizes.
I found some information about this using readelf, but its not super clear to me whats going on. It also appears that readelf is a linux script? I found out that everything I need should be in the --debug-dump=inof section of the .out file?
Thanks!
Upvotes: 0
Views: 32
Reputation: 61351
The information that you want is available in the debug info, but it's not readily available. The amount of DWARF parsing that needs to be done is considerable.
readelf --debug-dump=info
will give you a dump of the DIE tree, but then you will have to perform a ton of navigation and reference chasing. You could parse the output of readelf, or you could write your own parser with a DWARF library of your choice (libdwarf
, pyelftools
, gimli
to name a few). Depends on what language you'd be using.
For a quick look of what the DWARF DIE tree is like internally, try DWARF Explorer (https://github.com/sevaa/dwex). Full disclosure: I wrote that.
EDIT: there are some DWARF parsing tools that convert DWARF in a binary into an easier to parse format (usually JSON). Here is one: https://github.com/volatilityfoundation/dwarf2json . This might be your happy place - all the low level debugging info in a format suitable for machine analysis, but none of that pesky DWARF parsing. That tool has a "dump symbols" mode too.
Upvotes: 0