扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共8页)
08048458 <_fini>: 8048458: 55 push %ebp 8048459: 89 e5 mov %esp,%ebp 804845b: 53 push %ebx 804845c: e8 a7 fe ff ff call 8048308 <__i686.get_pc_thunk.bx> 8048461: 81 c3 13 11 00 00 add $0x1113,%ebx 8048467: 83 ec 04 sub $0x4,%esp 804846a: e8 9d fe ff ff call 804830c <__do_global_dtors_aux> 804846f: 83 c4 04 add $0x4,%esp 8048472: 5b pop %ebx 8048473: 5d pop %ebp 8048474: c3 ret
对于那些着迷于底层编程细节的程序员来说,这是一个功能非常强大的工具,可用于研究编译器和汇编器的输出。细节信息,比如这段代码中所显示的这些信息,可以揭示有关本地处理器本身运行方式的很多内容。对该处理器制造商提供的技术文档进行深入的研究,您可以收集关于一些有价值的信息,通过这些信息可以深入地了解内部的运行机制,因为功能程序提供了清晰的输出。
类似地,readelf 程序也可以清楚地列出目标文件中的内容。输入下面的命令,您将可以看到这一点:
readelf -all a.out |
这个命令生成的输出如清单 4 所示。ELF Header 为该文件中所有段入口显示了详细的摘要。在列举出这些 Header 中的内容之前,您可以看到 Header 的具体数目。在研究一个较大的目标文件时,该信息可能非常有用。
ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: Intel 80386 Version: 0x1 Entry point address: 0x80482c0 Start of program headers: 52 (bytes into file) Start of section headers: 3504 (bytes into file) Flags: 0x0 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 7 Size of section headers: 40 (bytes) Number of section headers: 34 Section header string table index: 31 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .interp PROGBITS 08048114 000114 000013 00 A 0 0 1 [ 2] .note.ABI-tag NOTE 08048128 000128 000020 00 A 0 0 4 [ 3] .hash HASH 08048148 000148 00002c 04 A 4 0 4 [ 4] .dynsym DYNSYM 08048174 000174 000060 10 A 5 1 4 [ 5] .dynstr STRTAB 080481d4 0001d4 00005e 00 A 0 0 1 [ 6] .gnu.version VERSYM 08048232 000232 00000c 02 A 4 0 2 [ 7] .gnu.version_r VERNEED 08048240 000240 000020 00 A 5 1 4 [ 8] .rel.dyn REL 08048260 000260 000008 08 A 4 0 4 [ 9] .rel.plt REL 08048268 000268 000010 08 A 4 11 4 [10] .init PROGBITS 08048278 000278 000017 00 AX 0 0 1 [11] .plt PROGBITS 08048290 000290 000030 04 AX 0 0 4 [12] .text PROGBITS 080482c0 0002c0 000198 00 AX 0 0 4 [13] .fini PROGBITS 08048458 000458 00001d 00 AX 0 0 1 [14] .rodata PROGBITS 08048478 000478 000015 00 A 0 0 4 [15] .eh_frame PROGBITS 08048490 000490 000004 00 A 0 0 4 [16] .ctors PROGBITS 08049494 000494 000008 00 WA 0 0 4 [17] .dtors PROGBITS 0804949c 00049c 000008 00 WA 0 0 4 [18] .jcr PROGBITS 080494a4 0004a4 000004 00 WA 0 0 4 [19] .dynamic DYNAMIC 080494a8 0004a8 0000c8 08 WA 5 0 4 [20] .got PROGBITS 08049570 000570 000004 04 WA 0 0 4 [21] .got.plt PROGBITS 08049574 000574 000014 04 WA 0 0 4 [22] .data PROGBITS 08049588 000588 00000c 00 WA 0 0 4 [23] .bss NOBITS 08049594 000594 000004 00 WA 0 0 4 [24] .comment PROGBITS 00000000 000594 000126 00 0 0 1 [25] .debug_aranges PROGBITS 00000000 0006c0 000088 00 0 0 8 [26] .debug_pubnames PROGBITS 00000000 000748 000025 00 0 0 1 [27] .debug_info PROGBITS 00000000 00076d 00022b 00 0 0 1 [28] .debug_abbrev PROGBITS 00000000 000998 000076 00 0 0 1 [29] .debug_line PROGBITS 00000000 000a0e 0001bb 00 0 0 1 [30] .debug_str PROGBITS 00000000 000bc9 0000bf 01 MS 0 0 1 [31] .shstrtab STRTAB 00000000 000c88 000127 00 0 0 1 [32] .symtab SYMTAB 00000000 001300 000520 10 33 63 4 [33] .strtab STRTAB 00000000 001820 0002d2 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x08048034 0x08048034 0x000e0 0x000e0 R E 0x4 INTERP 0x000114 0x08048114 0x08048114 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.2] LOAD 0x000000 0x08048000 0x08048000 0x00494 0x00494 R E 0x1000 LOAD 0x000494 0x08049494 0x08049494 0x00100 0x00104 RW 0x1000 DYNAMIC 0x0004a8 0x080494a8 0x080494a8 0x000c8 0x000c8 RW 0x4 NOTE 0x000128 0x08048128 0x08048128 0x00020 0x00020 R 0x4 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4 Section to Segment mapping: Segment Sections... 00 01 .interp 02 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame 03 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 04 .dynamic 05 .note.ABI-tag 06 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。