Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objdump and resolving linkage of local function calls?

Tags:

linux

objdump

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.

like image 943
Peeter Joot Avatar asked Jan 24 '12 19:01

Peeter Joot


People also ask

What does objdump do?

objdump displays information about one or more object files. The options control what particular information to display. This information is mostly useful to programmers who are working on the compilation tools, as opposed to programmers who just want their program to compile and work.

Which command would you use to Dissassemble a object file?

Passing --disassemble=SYMBOL to objdump will disassemble only the specified function. No need to pass the start address and the end address.

Which parameter of objdump is used to show all disassembled output of an executable?

Similarly, you can use the -D command-line option to make objdump display assembler contents of all sections, and -S option to make sure the tool intermixes source code with disassembly.


1 Answers

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

Yes: use objdump -dr foo.o

like image 122
Employed Russian Avatar answered Nov 15 '22 16:11

Employed Russian