当前位置:
首页 >
C语言再学习-- readelf、objdump、nm使用详解
发布时间:2025/3/15
36
豆豆
生活随笔
收集整理的这篇文章主要介绍了
C语言再学习-- readelf、objdump、nm使用详解
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
在其他文章里,这三个指令用了好多次了,但是没有真正总结他们的用法,现在来讲解一下。
参看:readelf命令
参看:objdump命令
参看:nm命令
常用选项:
(1)使用 readelf 显示一个或者多个elf格式的目标文件的信息
readelf -h add.o (-h 显示elf文件开始的文件头信息)
# readelf -h add.o ELF Header:Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32Data: 2's complement, little endianVersion: 1 (current)OS/ABI: UNIX - System VABI Version: 0Type: REL (Relocatable file)Machine: Intel 80386Version: 0x1Entry point address: 0x0Start of program headers: 0 (bytes into file)Start of section headers: 252 (bytes into file)Flags: 0x0Size of this header: 52 (bytes)Size of program headers: 0 (bytes)Number of program headers: 0Size of section headers: 40 (bytes)Number of section headers: 11Section header string table index: 8
(2)使用 objdump 查看目标文件或者可执行的目标文件
objdump -d add.o (-d 从objfile中反汇编那些特定指令机器码的section。 )
# objdump -d add.o add.o: file format elf32-i386Disassembly of section .text:00000000 <add_int>:0: 55 push %ebp1: 89 e5 mov %esp,%ebp3: 8b 45 0c mov 0xc(%ebp),%eax6: 8b 55 08 mov 0x8(%ebp),%edx9: 01 d0 add %edx,%eaxb: 5d pop %ebpc: c3 ret
(3)使用 nm 显示二进制目标文件的符号表,包括符号地址、符号类型、符号名等
nm add.o
# nm add.o 00000000 T add_int
总结
以上是生活随笔为你收集整理的C语言再学习-- readelf、objdump、nm使用详解的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: C语言再学习 -- 时间函数
- 下一篇: 互联网晚报 | 4月08日 星期五 |