How to check the values of a struct from an image/binary file?

217 views Asked by At

Is there anyway i can look into the values of a structure after compilation? objdump -td gives the function definitions and only the address where the structure is stored. The problem is i am getting a wrong address for one of the threads/functions in a structure when i run a program. The target mcu is lpc1347 (ARM Cortex-m3).

1

There are 1 answers

0
Eugeniu Rosca On BEST ANSWER

objdump parses object files (products of the compiler), which are relocatable (not executable) ELF files. At this stage, there is no such notion as the memory address these compiled pieces will run at.

You have the following possibilities:

  • Link your *.obj files into the final non-stripped (-g passed to compiler) executable ELF image and parse it using readelf.
  • Generate the linker map file by adding -Wl,-Map,file.map to your LDFLAGS and see the output sections and addresses your data is located at in the map file.
  • Use a debugger/gdb.