A little similar with Where are static variables stored (data segment or heap or BSS)?,but not the same one.
Now I get a other process’s variable’s address like:0x10fb90,where is this variable stored(data segment or heap or BSS), could i get the location just from the process’s pid and the variable’s address?
I am working on osx using obj-c and c.
You have 2 options.
1. Use
objdumpSomething like
2. Use gcc’s map option to generate a map file
Compile something like this in gcc
and now
Both these methods will show your variable’s location, if at all the address you supplied exits.
PS: The link I’ve added for the
map fileshows an example map file generated by Visual Studio linkers, but the format is typically similar in most of the map file formats generated by various linkers