常用工具:readelf、size、nm、strip、strings、objdump、objcopy、addr2line
readelf:读可执行文件的elf头
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 ELF Header: 2 Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 3 Class: ELF32 4 Data: 2's complement, little endian 5 Version: 1 (current) 6 OS/ABI: UNIX - System V 7 ABI Version: 0 8 Type: DYN (Shared object file) 9 Machine: ARM 10 Version: 0x1 11 Entry point address: 0x34800000 12 Start of program headers: 52 (bytes into file) 13 Start of section headers: 729812 (bytes into file) 14 Flags: 0x5000002, has entry point, Version5 EABI 15 Size of this header: 52 (bytes) 16 Size of program headers: 32 (bytes) 17 Number of program headers: 3 18 Size of section headers: 40 (bytes) 19 Number of section headers: 25 20 Section header string table index: 22
size:读取可执行程序的大小
binge@ubuntu14:~/user/my_share/u-boot-2012.10$ size u-boot
text data bss dec hex filename
149612 3304 8384 161300 27614 u-boot
nm:常用于查看可执行程序的符号列表(便于人去观看与程序执行无关的列表)
T:全局函数标签 t:被static修饰的函数区间 D:全局变量区 d:局部变量区被static修饰
strip:剔除符号列表
strings:查看可执行程序中的常量字符串(是否剔除符号表与此命令成功与否无关)
objcopy:剔除可执行文件的头信息
代码调试指令:objdump 、hexdump
反汇编查看文件(输出C源代码和反汇编出来的指令对照的格式) arm-linux-objdump -S 文件名
在管道中查看:arm-linux-objdump -S 文件名|less