Книга: Embedded Linux Primer: A Practical, Real-World Approach
13.5.3. objdump
13.5.3. objdump
The objdump utility has considerable overlap with the readelf tool. However, one of the more useful features of objdump is its capability to display disassembled object code. Listing 13-17 provides an example of disassembly of the .text section of the simple "hello world" PowerPC version. We include only the main() routine, to save space. The entire dump, including C library prologue and epilogue, would consume many pages.
Listing 13-17. Disassembly Using objdump
$ ppc_82xx-objdump -S -m powerpc:common -j .text hello
...
10000488 <main>:
10000488: 94 21 ff e0 stwu r1,-32(r1)
1000048c: 7c 08 02 a6 mflr r0
10000490: 93 e1 00 1c stw r31,28(r1)
10000494: 90 01 00 24 stw r0,36(r1)
10000498: 7c 3f 0b 78 mr r31,r1
1000049c: 90 7f 00 08 stw r3,8(r31)
100004a0: 90 9f 00 0c stw r4,12(r31)
100004a4: 3d 20 10 00 lis r9,4096
100004a8: 38 69 08 54 addi r3,r9,2132
100004ac: 4c c6 31 82 crclr 4*cr1+eq
100004b0: 48 01 05 11 bl 100109c0
<__bss_start+0x60>
100004b4: 38 00 00 00 li r0,0
100004b8: 7c 03 03 78 mr r3,r0
100004bc: 81 61 00 00 lwz r11,0(r1)
100004c0: 80 0b 00 04 lwz r0,4(r11)
100004c4: 7c 08 03 a6 mtlr r0
100004c8: 83 eb ff fc lwz r31,-4(r11)
100004cc: 7d 61 5b 78 mr r1,r11
100004d0: 4e 80 00 20 blr
...
Much of the code from the simple main() routine is stack frame creation and destruction. The actual call to printf() is represented by the branch link (bl) instruction near the center of the listing at address 0x100004b0. This is a PowerPC function call. Because this program was compiled as a dynamically linked object, we will not have an address for the printf() function until runtime, when it is linked with the shared library printf() routine. Had we compiled this as a statically linked object, we would see the symbol and corresponding address for the call to printf().