If you have an object file, how do you get the initialized value of a global variable in that object file's data segment? For example, say I've done the following:
# I'm interested in the variable foo inside bar.o in libbar.a:
$ ar -x libbar.a bar.o
$ nm --print-size bar.o | grep foo
00000048 00000004 D foo
This tells me that foo
is at offset 0x48 in the data segment with size 4, but how do I obtain the actual initialized value it obtains upon load?