In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the readelf command in GNU Binutils. It is very detailed and has a certain reference value. Friends who are interested must finish it!
When debugging libdrm, see which libraries libdrm.so depends on, use the readelf command, and simply record the usage of the command.
1. Display ELF file header information
Root@ubuntu:/home/run/code# readelf-h libdrm.so.2.4.0ELF Header: Magic: 7f 45 4c 46 02 01 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. Display dynamic segment information
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
This command can see which libraries the dynamic library depends on, and it is convenient to update the required dynamic libraries when debugging the dynamic libraries.
Readelf can view: executable files, dynamic libraries (.so) and static libraries (.a).
3. Display segment table information
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 000 [1] .n ote.gnu.build-i NOTE 0000000000000190 00000190 0000000000000024 0000000000000000 A 00 4 [2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 000000000000056c 0000000000000000 A 3 08 [3] .dynsym DYNSYM 0000000000000728 00000728 00000000000016e0 0000000000000018 A 4 3 8 [4] .dynstr STRTAB 0000000000001e08 00001e08 0000000000000de2 0000000000000000 A 00 1 [5] .gnu.version VERSYM 0000000000002bea 00002bea 00000000000001e8 0000000000000002 A 3 02 [6] .gnu.version _ r VERNEED 0000000000002dd8 00002dd8 0000000000000060 0000000000000000 A 4 38 [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 00 4 [10] .plt PROGBITS 0000000000003740 00003740 0000000000000570 0000000000000010 AX 00 16 [11] .text PROGBITS 0000000000003cb0 00003cb0 0000000000007f84 0000000000000000 AX 00 8 [12] .fini PROGBITS 000000000000bc34 0000bc34 0000000000000010 0000000000000000 AX 004 [13] .rodata PROGBITS 000000000000bc48 0000bc48 0000000000001658 0000000000000000 A 00 8 [14] .eh _ frame PROGBITS 000000000000d2a0 0000d2a0 0000000000000004 0000000000000000 A 00 4 [15] .init _ array INIT_ARRAY 000000000001dda0 0000dda0 0000000000000008 0000000000000008 WA 008 [16] .fini _ array FINI_ARRAY 000000000001dda8 0000dda8 0000000000000008 0000000000000008 WA 008 [17] .jcr PROGBITS 000000000001ddb0 0000ddb0 0000000000000008 0000000000000000 WA 008 [18] .dynamic DYNAMIC 000000000001ddb8 0000ddb8 00000000000001f0 0000000000000010 WA 40 8 [19] .got PROGBITS 000000000001dfa8 0000dfa8 0000000000000040 0000000000000008 WA 008 [20] .got.plt PROGBITS 000000000001dfe8 0000dfe8 00000000000002c0 0000000000000008 WA 008 [21] .data PROGBITS 000000000001e2a8 0000e2a8 0000000000000008 0000000000000000 WA 008 [22] .bss NOBITS 000000000001e2b0 0000e2b0 00000000000009b8 0000000000000000 WA 008 [23] .gnu _ debuglink PROGBITS 0000000000000000 0000e2b0 0000000000000034 0000000000000000 001 [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) display symbol table information
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: 00000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000003720 0 SECTION LOCAL DEFAULT 9 2: 000000000001ddb0 0 SECTION LOCAL DEFAULT 17 3: 00000000000000 0 FUNC GLOBAL DEFAULT UND memcpy@GLIBC_2.17 (2) 4: 00000000000000 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: 00000000000000 0 FUNC WEAK DEFAULT UND _ _ cxa_finalize@GLIBC_2.17 (2) 10: 00000000000000 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).
The symbol table holds all global variables and functions defined or used by the program.
5) display all information
It is equivalent to-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 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 000 [1]. Note.gnu.build-i NOTE 0000000000000190 00000190 0000000000000024 0000000000000000 A 00 4 [2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 000000000000056c 0000000000000000 A 3 08 [3] .dynsym DYNSYM 0000000000000728 00000728 00000000000016e0 0000000000000018 A 4 3 8 [4] .dynstr STRTAB 0000000000001e08 00001e08 0000000000000de2 0000000000000000 A 00 1 [5] .gnu.version VERSYM 0000000000002bea 00002bea
The readelf command can use readelf-h to get the usage of other parameters.
The above is all the contents of the article "how to use readelf commands in GNU Binutils". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.