Extracting structure elements address and types from elf file.

Dec 23, 2013 3 Replies

Hi,



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.



Thanks



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

Mel.

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.

Thanks, that looks to be a potentially good solution.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required