GNUBinutils中readelf命令怎么用
这篇文章主要介绍GNU Binutils中readelf命令怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
创新互联公司自2013年创立以来,是专业互联网技术服务公司,拥有项目网站建设、成都网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元思茅做网站,已为上家服务,为思茅各地企业和个人服务,联系电话:13518219792
在调试libdrm
时,查看libdrm.so
依赖哪些库,用到了readelf
命令,简单记录下该命令的用法。
1、显示ELF文件头信息
root@ubuntu:/home/run/code# readelf -h libdrm.so.2.4.0ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: AArch74 Version: 0x1 Entry point address: 0x3cb0 Start of program headers: 64 (bytes into file) Start of section headers: 58304 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 6 Size of section headers: 64 (bytes) Number of section headers: 25 Section header string table index: 24
2、显示动态段信息
root@ubuntu:/home/run/code# readelf -d libdrm.so.2.4.0Dynamic section at offset 0xddb8 contains 27 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libm.so.6] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch74.so.1] 0x000000000000000e (SONAME) Library soname: [libdrm.so.2] 0x000000000000000c (INIT) 0x3720 0x000000000000000d (FINI) 0xbc34 0x0000000000000019 (INIT_ARRAY) 0x1dda0 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) 0x000000000000001a (FINI_ARRAY) 0x1dda8 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) 0x000000006ffffef5 (GNU_HASH) 0x1b8 0x0000000000000005 (STRTAB) 0x1e08 0x0000000000000006 (SYMTAB) 0x728 0x000000000000000a (STRSZ) 3554 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0x1dfe8 0x0000000000000002 (PLTRELSZ) 2040 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x2f28 0x0000000000000007 (RELA) 0x2e38 0x0000000000000008 (RELASZ) 240 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000006ffffffe (VERNEED) 0x2dd8 0x000000006fffffff (VERNEEDNUM) 3 0x000000006ffffff0 (VERSYM) 0x2bea 0x000000006ffffff9 (RELACOUNT) 3 0x0000000000000000 (NULL) 0x0
该命令可查看该动态库依赖哪些库,方便动态库调试时,更新所需的动态库。
readelf
可查看:可执行文件,动态库(.so)和静态库(.a)。
3.显示段表信息
root@ubuntu:/home/run/code# readelf -S libdrm.so.2.4.0There are 25 section headers, starting at offset 0xe3c0:Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .note.gnu.build-i NOTE 0000000000000190 00000190 0000000000000024 0000000000000000 A 0 0 4 [ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 000000000000056c 0000000000000000 A 3 0 8 [ 3] .dynsym DYNSYM 0000000000000728 00000728 00000000000016e0 0000000000000018 A 4 3 8 [ 4] .dynstr STRTAB 0000000000001e08 00001e08 0000000000000de2 0000000000000000 A 0 0 1 [ 5] .gnu.version VERSYM 0000000000002bea 00002bea 00000000000001e8 0000000000000002 A 3 0 2 [ 6] .gnu.version_r VERNEED 0000000000002dd8 00002dd8 0000000000000060 0000000000000000 A 4 3 8 [ 7] .rela.dyn RELA 0000000000002e38 00002e38 00000000000000f0 0000000000000018 A 3 0 8 [ 8] .rela.plt RELA 0000000000002f28 00002f28 00000000000007f8 0000000000000018 AI 3 20 8 [ 9] .init PROGBITS 0000000000003720 00003720 0000000000000014 0000000000000000 AX 0 0 4 [10] .plt PROGBITS 0000000000003740 00003740 0000000000000570 0000000000000010 AX 0 0 16 [11] .text PROGBITS 0000000000003cb0 00003cb0 0000000000007f84 0000000000000000 AX 0 0 8 [12] .fini PROGBITS 000000000000bc34 0000bc34 0000000000000010 0000000000000000 AX 0 0 4 [13] .rodata PROGBITS 000000000000bc48 0000bc48 0000000000001658 0000000000000000 A 0 0 8 [14] .eh_frame PROGBITS 000000000000d2a0 0000d2a0 0000000000000004 0000000000000000 A 0 0 4 [15] .init_array INIT_ARRAY 000000000001dda0 0000dda0 0000000000000008 0000000000000008 WA 0 0 8 [16] .fini_array FINI_ARRAY 000000000001dda8 0000dda8 0000000000000008 0000000000000008 WA 0 0 8 [17] .jcr PROGBITS 000000000001ddb0 0000ddb0 0000000000000008 0000000000000000 WA 0 0 8 [18] .dynamic DYNAMIC 000000000001ddb8 0000ddb8 00000000000001f0 0000000000000010 WA 4 0 8 [19] .got PROGBITS 000000000001dfa8 0000dfa8 0000000000000040 0000000000000008 WA 0 0 8 [20] .got.plt PROGBITS 000000000001dfe8 0000dfe8 00000000000002c0 0000000000000008 WA 0 0 8 [21] .data PROGBITS 000000000001e2a8 0000e2a8 0000000000000008 0000000000000000 WA 0 0 8 [22] .bss NOBITS 000000000001e2b0 0000e2b0 00000000000009b8 0000000000000000 WA 0 0 8 [23] .gnu_debuglink PROGBITS 0000000000000000 0000e2b0 0000000000000034 0000000000000000 0 0 1 [24] .shstrtab STRTAB 0000000000000000 0000e2e4 00000000000000da 0000000000000000 0 0 1Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), p (processor specific)
4)显示符号表信息
root@ubuntu:/home/run/code# readelf -s libdrm.so.2.4.0Symbol table '.dynsym' contains 244 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000003720 0 SECTION LOCAL DEFAULT 9 2: 000000000001ddb0 0 SECTION LOCAL DEFAULT 17 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memcpy@GLIBC_2.17 (2) 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memmove@GLIBC_2.17 (2) 5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.17 (2) 6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __sprintf_chk@GLIBC_2.17 (2) 7: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab 8: 0000000000000000 0 FUNC GLOBAL DEFAULT UND readlink@GLIBC_2.17 (2) 9: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.17 (2) 10: 0000000000000000 0 FUNC GLOBAL DEFAULT UND opendir@GLIBC_2.17 (2) 11: 0000000000000000 0 FUNC GLOBAL DEFAULT UND clock_gettime@GLIBC_2.17 (2) 12: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND stderr@GLIBC_2.17 (2) 13: 0000000000000000 0 FUNC GLOBAL DEFAULT UND qsort@GLIBC_2.17 (2) ...
符号表保存程序定义或使用的所有全局变量和函数。
5)显示所有信息
等同于-h -l -S -s -r -d -V -A -I。
root@ubuntu:/home/run/code# readelf -a libdrm.so.2.4.0ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: AArch74 Version: 0x1 Entry point address: 0x3cb0 Start of program headers: 64 (bytes into file) Start of section headers: 58304 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 6 Size of section headers: 64 (bytes) Number of section headers: 25 Section header string table index: 24Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .note.gnu.build-i NOTE 0000000000000190 00000190 0000000000000024 0000000000000000 A 0 0 4 [ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 000000000000056c 0000000000000000 A 3 0 8 [ 3] .dynsym DYNSYM 0000000000000728 00000728 00000000000016e0 0000000000000018 A 4 3 8 [ 4] .dynstr STRTAB 0000000000001e08 00001e08 0000000000000de2 0000000000000000 A 0 0 1 [ 5] .gnu.version VERSYM 0000000000002bea 00002bea
readelf
命令可以使用readelf -h
获取其它参数的用法。
以上是“GNU Binutils中readelf命令怎么用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
当前题目:GNUBinutils中readelf命令怎么用
标题来源:http://myzitong.com/article/ijoegg.html