Skip to content

What is readelf Linux command?

The readelf command in Linux provides detailed information about ELF files, including headers, sections, and symbols. It is a powerful tool for developers and system administrators to analyze executables and libraries.

readelf Syntax:

Terminal window
readelf [options] elf-file

readelf Options:

OptionDescription
-aEquivalent to -h -l -S -s -r -d -V -A -I.
-hDisplay the ELF file header.
-lDisplay the program headers.
-SDisplay the sections’ headers.
-sDisplay the symbol table.
-rDisplay the relocations.
-dDisplay the dynamic section.
-VDisplay the version sections.
-ADisplay the special sections.
-IDisplay the information sections.
-eDisplays the headers read from the section headers.
-pDisplays section names instead of numbers.
-uDisplays the symbol table name instead of number.
-w[lLiaprmfFsoRt]Enable warnings for various conditions.
-x Displays the contents of the file at the specified offset.

Parameters:

ParameterDescription
elf-fileThe ELF file to be analyzed.

readelf Command Usage Examples:

Displaying the ELF Header of a Binary File

Terminal window
readelf -h binary_file

Displays the ELF header information of the specified binary file.

Displaying Symbol Table Information

Terminal window
readelf -s binary_file

Displays the symbol table information of the specified binary file.

Displaying Section Headers

Terminal window
readelf -S binary_file

Displays the section headers of the specified binary file.

Displaying Dynamic Section Information

Terminal window
readelf -d binary_file

Displays the dynamic section information of the specified binary file.

Displaying Program Headers

Terminal window
readelf -l binary_file

Displays the program headers of the specified binary file.

How do I use readelf in Linux?

To use the readelf command in bash, execute the following command:

Terminal window
readelf --file-header <executable_file>

What information can I extract with readelf?

You can extract various information such as the file header, section headers, program headers, symbol tables, dynamic section, relocation entries, and notes from an executable file using readelf in Linux.

How can I display the section headers of an executable file with readelf?

To display the section headers of an executable file using readelf, run the following command:

Terminal window
readelf --sections <executable_file>

How do I view the dynamic section information of a binary file with readelf?

To view the dynamic section information of a binary file using readelf, use the following command:

Terminal window
readelf --dynamic <executable_file>

Can readelf display symbol tables from an executable file?

Yes, readelf can display symbol tables from an executable file in Linux. You can do this by running the following command:

Terminal window
readelf --syms <executable_file>

How to extract the program headers of an executable file with readelf?

You can extract the program headers of an executable file using readelf by running the command:

Terminal window
readelf --program-headers <executable_file>

Is it possible to show relocation entries with readelf?

Yes, it is possible to show relocation entries from an executable file using readelf. Execute the following command to display the relocation entries:

Terminal window
readelf --relocs <executable_file>

How can I examine the symbol version tables of an executable file with readelf?

To examine the symbol version tables of an executable file using readelf, use the following command:

Terminal window
readelf --version <executable_file>

Applications of the readelf command

  • Displaying information about ELF files
  • Analyzing object files and shared libraries
  • Extracting detailed information about the sections, segments, symbols, and other aspects of ELF files
  • Inspecting the dynamic linking information of ELF files
  • Verifying the architecture and attributes of ELF files
  • Understanding the structure and layout of ELF files