问题
Is there a way to get the full address in objdump?
Command being used is: objdump -d progname
The leading zeros are the incorrect. The addresses should be as follows:
The last three values in the address are correct; but, I'd much like the full address to be shown in objdump.
回答1:
Before your application gets loaded, you cannot tell where it will end in the memory.
Try the following code:
#include <stdio.h>
int main()
{
printf("%p\n", main);
}
Compile it with gcc test.c
and run several times.
My results show:
0x55f71f8936b0
0x5630ed7ff6b0
0x558a18eea6b0
...
So you can't know for sure where it will end in the memory. I believe it was not always the case, and this behaviour is intended as a security "thingy". I wouldn't be surprised if older kernel/loaders gave the same address on each run. I do not know that for sure, though.
Of course objdump
will give you relative addresses:
00000000000006b0 <main>:
Keep in mind that the output of this program does not give you physical addresses, they are still virtual.
The point is that addresses dumped by objdump
are a responsibility of the linker and actual virtual addresses from each execution are there because of the loader.
回答2:
In addition to the accepted answer:
To get the right addresses, you run the program in gdb, then type start, then do "disas functionname" and it shows the right addresses now.
来源:https://stackoverflow.com/questions/45493756/objdump-not-showing-complete-address