Extracting structure elements address and types from elf file.


Does anyone know of some readily available API or C functions that will go through an elf file to extract the symbol information for structures?

I'm just trying to avoid having to write my own based on readelf as it could be a bit of a long task.

For example if I have an embedded struct and variable liek this:

typedef struct { unsigned int varA; unsigned int varB; }T_myStruct;

T_myStruct data;

I want the address and type of not only data, but preferably data.varA and data.varB

To be clear the extraction of data from the elf file will be in a simple debugger application, not in the embedded code.


Reply to
Loading thread data ...

I notice a Ubuntu (therefore probably Debian) package libelf-dev. Also maybe the command "readelf --all /usr/lib/libelf.so.1".


Reply to
Mel Wilson

By far the easiest would probably be to just write a little script for gdb.

Agreed. Nobody in full command of their wits wants to write yet another DWARF debug information parser.

Reply to
Hans-Bernhard Bröker

Thanks, that looks to be a potentially good solution.

Reply to

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.