Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the common command readelf in Linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Linux commonly used command readelf how to use, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Linux commonly used command readelf command is used to display read information in ELF files, and you can also use the man command to get a full picture of it. It is used to display information about one or more target files in elf format, and you can control what information is displayed through its options.

Format: readelf elf-file (s) about ELF files: ELF file type:

A) Relocatable files: users work with other target files to create executable files or share target files, such as lib*.a files.

B) executable file: used to generate process image and load memory execution, such as compiled executable file a.out.

C) shared object files: used to generate elf object files with other shared object files or relocatable files or to create process images with execution files, such as lib*.so files.

The function of ELF file:

ELF files participate in the connection of programs (establishing a program) and the execution of programs (running a program), so files in elf format can be viewed from different perspectives:

A) if used for compilation and linking (relocatable files), the compiler and linker will treat the elf file as a collection of sections described in the section header table, which is optional.

B) if used for loading execution (executable), the loader will treat the elf file as a collection of segments described in the program header table, a segment may contain multiple sections, and the section header table is optional.

C) if it is a shared file, both contain.

The overall composition of the ELF file:

The elf file header describes the overall information of the elf file. Including: system-related, type-related, load-related, link-related.

Related to the system: the number of magic identified by elf files, as well as hardware and platform and other related information, increased the portability of elf files, making cross-compilation possible. Type correlation is the type mentioned earlier. Load related: including information about the program header table. Link related: section header table related information. 1234567 options (given in short and long form):

-a:-- all displays all information, which is equivalent to-h-l-S-s-r-d-V-A-I-h:-- file-header displays the header information at the beginning of the elf file. -l:-- program-headers;-- segments displays program header (segment header) information, if any. -S:-- section-headers;-- sections displays section header information (if any). -g:-- section-groups displays section group information, if any. -t:-- section-details displays the details of the section (of-S). -s:-- syms;-- symbols displays the items in the symbol table section, if any. -e:-- headers displays all the header information, which is equivalent to:-h-l-S-n:-- notes displays the information of the note segment (kernel comments). -r:-- relocs displays information about relocatable segments. -u:-- unwind displays unwind segment information. Currently, only unwind segment information of IA64 ELF is supported. -d:-- dynamic displays information about dynamic segments. -V:-- version-info displays information about the version segment. -A:-- arch-specific displays CPU architecture information. -D:-- use-dynamic uses the symbol table in dynamic segments to display symbols instead of using symbol segments. -XRV _ color _ color _ hextel _ dump = displays the contents of the specified segment in hexadecimal mode. Number specifies the index of the segment in the segment table, or the string specifies the name of the segment in the file. -w [liaprmfFsoR] or-debugdump [= line,=info,=abbrev,=pubnames,=aranges, = macro,=frames,=frames-interp,=str,=loc,=Ranges] displays what is specified in the debug segment. -I:-- histogram displays a bar chart of bucket list length when displaying symbols. -v:-- version displays the version information of readelf. -H:-- help displays the command line options supported by readelf. -W:-- wide wide line output. 1234567891011121314151617181920212232425272829303132333435363738394041424344 examples:

The contents of the main.c are as follows:

# include void my_print () {printf ("hello word");} int main () {my_print (); return 0;} 123456789101112 generate an a.out file, read it with the readelf command, and get:

Here, you can see the elf file of the executable file, of type EXEC (executable file), and it can be seen that the architecture of the file is Intel 80386.

Thank you for reading this article carefully. I hope the article "how to use Linux commands readelf" shared by the editor will be helpful to everyone. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report