正如从该输出中看到的,简单的 a.out Hello World 文件中包含了大量有价值的细节信息,包括版本信息、柱状图、各种符号类型的表格,等等 。通过使用本文中介绍的这几种工具分析目标文件,您可以慢慢地对可执行程序进行研究 。
除了所有这些段之外,编译器可以将调试信息放入到目标文件中,并且还可以显示这些信息 。输入下面的命令,仔细分析编译器的输出(假设您扮演了调试程序的角色):
readelf --debug-dump a.out | less
这个命令生成的输出如清单 5 所示 。调试工具,如 GDB,可以读取这些调试信息,并且当程序在调试器中运行的同时,您可以使用该工具显示更具描述性的标记,而不是对代码进行反汇编时的原始地址值 。
清单 5. 该程序中的调试信息The section .debug_aranges contains:
Length:28
Version: 2
Offset into .debug_info: 0
Pointer Size: 4
Segment Size: 0
Address Length
080482c0 34
Length:52
Version: 2
Offset into .debug_info: 10b
Pointer Size: 4
Segment Size: 0
Address Length
08048308 4
08048458 18
08048278 11
080482e4 36
Length:44
Version: 2
Offset into .debug_info: 19b
Pointer Size: 4
Segment Size: 0
Address Length
08048308 4
0804846f 6
0804828d 2
Contents of the .debug_pubnames section:
Length: 33
Version: 2
Offset into .debug_info section: 122
Size of area in .debug_info section: 145
Offset Name
121 _IO_stdin_used
The section .debug_info contains:
Compilation Unit @ offset 0x0:
Length:118
Version:2
Abbrev Offset: 0
Pointer Size: 4
<0>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list: 0
DW_AT_low_pc : 0x80482c0
DW_AT_high_pc : 0x80482e2
DW_AT_name: ../sysdeps/i386/elf/start.S
DW_AT_comp_dir: /build/buildd/glibc-2.3.6/build-tree/glibc-2.3.6/csu
DW_AT_producer: GNU AS 2.16.91
DW_AT_language: 32769 (MIPS assembler)
Compilation Unit @ offset 0x7a:
Length:141
Version:2
Abbrev Offset: 20
Pointer Size: 4
<0><85>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list: 0x5b
DW_AT_high_pc : 0x80482e4
DW_AT_low_pc : 0x80482e4
DW_AT_producer: (indirect string, offset: 0x62): GNU C 3.4.6
DW_AT_language: 1 (ANSI C)
DW_AT_name: (indirect string, offset: 0x0): init.c
DW_AT_comp_dir: (indirect string, offset: 0x11): /build/buildd/...
<1><9f>: Abbrev Number: 2 (DW_TAG_base_type)
DW_AT_name: (indirect string, offset: 0x90): unsigned int
DW_AT_byte_size: 4
DW_AT_encoding: 7 (unsigned)
<1>: Abbrev Number: 2 (DW_TAG_base_type)
DW_AT_name: (indirect string, offset: 0x54): unsigned char
DW_AT_byte_size: 1
DW_AT_encoding: 8 (unsigned char)
<1>: Abbrev Number: 2 (DW_TAG_base_type)
DW_AT_name: (indirect string, offset: 0x9d): short unsigned int
DW_AT_byte_size: 2
DW_AT_encoding: 7 (unsigned)
<1>
DW_AT_name: (indirect string, offset: 0x8b): long unsigned int
DW_AT_byte_size: 4
DW_AT_encoding: 7 (unsigned)
<1>
DW_AT_name: (indirect string, offset: 0x56): signed char
DW_AT_byte_size: 1
DW_AT_encoding: 6 (signed char)
<1>
DW_AT_name: (indirect string, offset: 0x7): short int
DW_AT_byte_size: 2
DW_AT_encoding: 5 (signed)
<1>
DW_AT_name: int
DW_AT_byte_size: 4
DW_AT_encoding: 5 (signed)
推荐阅读
- 口令篇 UNIX操作系统的安全命令集
- 进行类Unix小型机系统管理的八项注意
- 类UNIX系统基础:文件安全与权限
- 在SCO Unix系统中实现业务数据的自动备份
- 构建SCO UNIX下的邮件系统
- sco unixware 7.1.1 全面学习资料
- SCO UNIX 系统下搭建电子邮件服务器
- undelete 如何在SCO UNIX下的反删除
- UNIX 常用指令介绍
- 对话 UNIX,第 7 部分: 命令行惯用语
