I would like to change the global structures in an ELF file. I would first like to know whether a global variable is a structure or not? But the only information I see is the name and the size of the variable.
1 Answer
You cannot find it. The ELF format has a very limited type information (and does not know if some global variable is a struct or an int; it knows mostly the sizeof the variable). See elf(5).
However, if you compile your program (and the libraries it is using) for debug support (e.g. with g++ -Wall -g). then the ELF file contains additional debug sections, often using the DWARF format. These information can be removed from an ELF file using the strip command. So see strip(1) & readelf(1) & objdump(1).
But you really want to use the source code. So get the source of the program (since Linux is mostly made of free software, this is generally possible) and recompile it (and of course study the source code of the program). Perhaps you want (but that does require weeks of work) to customize your compiler (e.g. by writing your own GCC plugin, or using GCC MELT, or customizing your Clang compiler) and use that to recompile the code (and process specifically all global variable declarations).
char[]andvoid *.