0

Using the map file I can find the address of any variable of my C software. I would like to have access to structure element addresses also, not only to the address to the struct.

Is there an easy way of getting this without needing to parse the whole code and look for the struct definitions or manually adding the offset to the struct variable? I can't seem to find anything helpful in the .map file alone but perhaps other compiler output files could have more information.

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Carlos
  • 105
  • 2
  • 14
  • 1
    Not in the map. That'd be most useless for your case. Notice that it doesn't even contain the types of the variables. However there are the *other* debugging data formats that *do* retain type info. – Antti Haapala -- Слава Україні Sep 11 '18 at 07:34
  • 1
    But structure members don't *have* addresses, not until you have an actual *instance* of the structure. And why do you need this? What is the problem knowing the "address" of structure members will solve? – Some programmer dude Sep 11 '18 at 07:35
  • I cannot figure out how to do that with the map file, but if your compiler supports DWARF, you will be able to find the address of the struct and the offset for each element. – Jose Sep 11 '18 at 07:50
  • Also note that the map-file is misleading. It can only show the location of global or static variables. Local variables, arguments or dynamically allocated data can't be in the map file. – Some programmer dude Sep 11 '18 at 07:52
  • What other debug files do you recommend to use? obj files? The beauty of .map files is that they are just text files and are very similar among different compilers so I can read them easily in different projects. I don't know how to read obj files and I am afraid they will be too much compiler dependent. – Carlos Sep 11 '18 at 08:00

0 Answers0