Common embedded Linux binary debugging tools (1)
ØReadelf
Readelf can be used to display information about executable files in ELF format. For example, you can use readelf to view the results of each section in hello. O as follows:
$ Readelf-s hello. o There are 15 section headers, starting at offset 0x228: Section headers: [Nr] Name type ADDR off size es flg lk inf al [0] Null 00000000 000000 000000 00 0 0 0 [1]. Text progbits 00000000 000034 20. AE 00 ax 0 0 4 [2]. Rel. Text rel 00000000 000754 000060 08 13 1 4 [3]. Data progbits 00000000 running E4 000000 00 wa 0 0 4 [4]. BSS nobits 00000000 running E4 000001 00 wa 0 0 4 [5]. rodata progbits 00000000 running E4 00000d 00 0 0 1 [6]. ctors progbit 00000000 Effecf 4 000004 00 wa 0 0 4 [7]. Rel. ctors rel 00000000 0007b4 000008 08 13 6 4 [8]. eh_frame progbit 00000000 Effecf 8 000090 00 0 0 4 [9]. Rel. eh_frame rel 00000000 0007bc 000028 08 13 8 4 [10]. Note. GNU-stack note 00000000 000188 000000 00 0 0 1 [11]. Comment progbits 00000000 000188 000034 00 0 0 1 [12]. shstrtab strtab 00000000 0001bc 20176a 00 0 0 1 [13]. symtab 00000000 000480 000180 10 14 E 4 [14]. strtab 00000000 000600 000153 00 0 0 1 Key to flags: W (write), A (alloc), x (execute), m (merge), S (strings) I (Info), L (link order), g (group), x (unknown) O (extra OS processing required) O (OS specific), P (processor specific) |
ØSize
The size command can list the size of each segment of the target file and the total size. By default, only one output line is generated for each module in each target file or archive file. Size can be used to quickly and easily understand the various sections of the ELF file, for example:
$ Size hello. o Text Data BSS dec hex filename 331 4 1 336 150 hello. o |
ØObjcopy
Objcopy is used to copy the content of a target file to another type of target file. It is generally used to copy or replace certain segments in the target file, or remove some segments.
ØStrings
Strings prints printable strings of a file. These strings must be at least 4 characters long. You can also use option-N to set the minimum length of the string. By default, it only prints printable characters in the initialization and loading segments of the target file. For other types of files, it prints printable characters of the entire file, this program is very helpful for understanding the content of non-text files.
ØStrip
Strip: discard all or specific symbols in the target file, which can be used to reduce the size of executable files and libraries. For more information, see the storage optimization section in the next chapter.
ØAddr2line
Addr2line: converts a program address to a file name and a row number. In the command line, give it an address and an executable file name, and it will use the debugging information of this executable file to indicate which file is on the given address and the row number. For specific examples, see how to find the C/C ++ source code with errors through the Register Pc value and addr2line tool in core dump analysis (Section 9.5.
ØLDD
LDD can be used to show which shared libraries are required for the execution file and where the Shared Library Loading manager finds the required shared library. For example:
# LDD hello Libstdc ++. so.5 =>/usr/lib/libstdc ++. so.5 (0x40026000) Libm. so.6 =>/lib/tls/libm. so.6 (0x400d9000) Libgcc_s.so.1 =>/lib/libgcc_s.so.1 (0x400fb000) Libc. so.6 =>/lib/tls/libc. so.6 (0x42000000) /Lib/ld-linux.so.2 =>/lib/ld-linux.so.2 (0x40000000) |
The most common feature of LDD is to solve the problem that the library cannot be found during the runtime, such as the error while loading shared libraries: libxxx. so "error. You can run LDD to check which library files are missing.
Http://www.top-e.org/jiaoshi/html? 163. html