gdb vs. objdump arm disassembler function branch name resolving

馋奶兔 提交于 2019-12-11 13:45:44

问题


I have a bit of strange question. If I use objdump -d for disassembling an ARM binary it can resolve the function (system library) names of branch instructions e.g.:

8404:   e581e000    str lr, [r1]
8408:   e59f0028    ldr r0, [pc, #40]   ; 8438 <address_of_message1>
840c:   ebffffc1    bl  8318 <printf@plt>
8410:   e59f0028    ldr r0, [pc, #40]   ; 8440 <address_of_scan_pattern>
8414:   e59f1028    ldr r1, [pc, #40]   ; 8444 <address_of_read>
8418:   ebffffc4    bl  8330 <scanf@plt>
841c:   e59f0018    ldr r0, [pc, #24]   ; 843c <address_of_message2>

So I see bl 8318 will call printf. When I use gdb and the disas command I get the disassembly without the function name (same code sample), see:

   0x00008408 <+8>:     ldr r0, [pc, #40]   ; 0x8438 <address_of_message1>
   0x0000840c <+12>:    bl  0x8318
   0x00008410 <+16>:    ldr r0, [pc, #40]   ; 0x8440 <address_of_scan_pattern>
   0x00008414 <+20>:    ldr r1, [pc, #40]   ; 0x8444 <address_of_read>
   0x00008418 <+24>:    bl  0x8330

In gdb I see only the branch to 0x8330.

Is it possible to resolve the function name also with gdb ?

Can anybody explain to me why objdump can resolve the name of system functin calls and gdb not ?


回答1:


gdb and GNU objdump use the same library (bfd) to read and interpret library, but it's statically compiled in. That means, that an old version of gdb could show less then a newer objdump.

I've tested a recent objdump and a recent gdb on i386 on a hello world and both show the same information.

Please check that you're using a recent gdb.

Note: the function printf@plt is not the printf itself, but a function pointing to the dynamic loader, that will load the real printf from a shared library when jump occurs



来源:https://stackoverflow.com/questions/34761759/gdb-vs-objdump-arm-disassembler-function-branch-name-resolving

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!