9

If I run objdump -d on a (linux amd64) .o file, function calls show up without the link time resolution done. Example:

  90:   66 89 44 24 1c          mov    %ax,0x1c(%rsp)
  95:   44 89 74 24 10          mov    %r14d,0x10(%rsp)
  9a:   e8 00 00 00 00          callq  9f <foo+0x9f>
  9f:   83 f8 ff                cmp    $0xffffffffffffffff,%eax
  a2:   74 5e                   je     102 <foo+0x102>

A branch within the function shows up properly, but the callq is just the stub put in for the linker (with four bytes of zeros available for the linker to put a proper address into).

Is there a way, without actually linking, to get an assembly listing that has the function names resolved? I don't care about the address that will eventually be used, just the name of the function. That info has got to be in the .o file, since the linker must consume it to do its job.

I ask because the shared lib that the code in question goes into is about 140Mb, and it takes a long time to run objdump -d on that to get the asm dump with all the function calls resolved to their actual names.

2
  • I've figured out a workaround for my specific problem. I can run nm to get the function address in our huge shared lib, and then run objdump with --start-address using that nm output. I'd still be interested in an answer to the original question though if it is possible. Commented Jan 24, 2012 at 19:55
  • 1
    Related: meaning of an entry in a relocation table of an object file for more details about relocation entries. Commented Jan 26, 2023 at 17:21

1 Answer 1

19

Is there a way, without actually linking, to get an assembly listing that has the function names resolved?

Yes: use objdump -dr foo.o

1
  • 3
    I like objdump -drwC -Mintel because -w and -C are nice, too: no line wrapping, and demangle C++ names. (I alias disas='objdump -drwC -Mintel' in my shell.) Commented Feb 11, 2019 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.