Search code examples
linuxobjdump

Objdump not showing complete address


Is there a way to get the full address in objdump? Command being used is: objdump -d progname

enter image description here

The leading zeros are the incorrect. The addresses should be as follows:

enter image description here

The last three values in the address are correct; but, I'd much like the full address to be shown in objdump.


Solution

  • 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.