看了很多文档,都是对ELF文件中的调试信息格式一带而过,包括《Linker & Loader》中也没有详细介绍。
我想获取调试信息中的数据结构相关的信息,结构大小,每个变量的名称,大小等信息。
|
通过objdump的命令,例如:tmp.o是elf文件,objdump参数应该为--sym
1、dump出符号表,objdumpppc --sym tmp.o > bootrom_sym.txt,内容如下:
tmp.o: file format elf32-powerpc
SYMBOL TABLE:
02c00000 l d .text00000000
02ce7cc0 l d .data00000000
02d0a1f0 l d .bss00000000
00000000 l d .PPC.EMB.apuinfo00000000
00000000 l d *ABS*00000000
00000000 l d *ABS*00000000
00000000 l d *ABS*00000000
00000000 l df *ABS*00000000 bootConfig.c
02ce7da8 l O .data00000078 netIf
02ce7e2c l O .data00000004 trapValue1
02ce7e30 l O .data00000004 trapValue2
02ce7f34 l O .data00000044 noticeChar.0
02d0a674 l O .bss00000004 noticeNum.1
02d0a678 l O .bss00000004 memTestRoundPass
02ce7f78 l O .data00000004 SEED_X
02ce7f7c l O .data00000004 SEED_Y
02ce7f80 l O .data00000004 a.2
02ce7f84 l O .data00000004 b.3
02c00184 l F .text00000058 memCheckRand
02c00200 l F .text00000278 movinv1
02c00478 l F .text000001d8 addr_tst1
02c00650 l F .text00000184 addr_tst2
02c007d4 l F .text00000284 modtst
02c00a58 l F .text00000204 movinvr
02c00c5c l F .text00000340 movinv32
02c00f9c l F .text00000188 bit_fade
02c01124 l F .text000003bc enhancedMemCheckMainLoop
02c014e0 l F .text000001d8 patchVecBase
02c018a0 l F .text00000184 CheckRam
02c093a4 l F .text000000c8 usrBootLineInit
02c08840 l F .text00000080 go
.....................................................
2、dump出汇编,objdumpppc --disassemble tmp.o > bootrom_asm.txt,内容如下:
tmp.o: file format elf32-powerpc
Disassembly of section .text:
02c00000 :
2c00000:94 21 ff f8 stwur1,-8(r1)
2c00004:7c 08 02 a6 mflrr0
2c00008:90 01 00 0c stwr0,12(r1)
2c0000c:4c c6 31 82 crclr4*cr1+eq
2c00010:48 00 16 a9 bl2c016b8
2c00014:80 01 00 0c lwzr0,12(r1)
2c00018:38 21 00 08 addir1,r1,8
2c0001c:7c 08 03 a6 mtlrr0
2c00020:4e 80 00 20 blr
02c00024 :
2c00024:94 21 ff f8 stwur1,-8(r1)
2c00028:7c 08 02 a6 mflrr0
2c0002c:90 01 00 0c stwr0,12(r1)
2c00030:48 08 88 09 bl2c88838
2c00034:48 0c 7b b9 bl2cc7bec
2c00038:48 09 70 15 bl2c9704c
2c0003c:48 0c 49 41 bl2cc497c
2c00040:48 0c 65 49 bl2cc6588
2c00044:48 0c 51 29 bl2cc516c
2c00048:48 0c 1f cd bl2cc2014
2c0004c:48 0c a9 ed bl2ccaa38
2c00050:48 0c 2e 19 bl2cc2e68
2c00054:3c a0 02 db lisr5,731
2c00058:3d 20 02 cf lisr9,719
2c0005c:80 89 4a 38 lwzr4,19000(r9)
2c00060:3c 60 02 db lisr3,731
2c00064:38 c0 01 00 lir6,256
2c00068:38 a5 c6 14 addir5,r5,-14828
2c0006c:38 63 b9 48 addir3,r3,-18104
2c00070:4c c6 31 82 crclr4*cr1+eq
2c00074:48 0a 12 4d bl2ca12c0
。。。。。。。。。。。
就这样,linux下面也有类似的工具。