readelf Command
The readelf command displays information about ELF (Executable and Linkable Format) files, such as executable files, object files, shared libraries, and core dumps. It is a crucial tool for developers and system administrators working with compiled binaries on Linux systems.
Syntax
Description
readelf is part of the GNU Binutils package and provides a human-readable representation of the contents of an ELF file. It can display various parts of the ELF file, including the ELF header, section headers, program headers, symbol table, relocation entries, and more.
Common uses include:
- Inspecting the architecture and properties of an executable.
- Debugging linking issues by examining symbol tables.
- Understanding the structure of compiled programs.
- Analyzing shared library dependencies.
Common Options
| Option | Description |
|---|---|
-h |
Display the ELF file header. |
-l |
Display the program headers (segments). |
-S |
Display the section headers. |
-s |
Display the symbol table. |
-r |
Display the relocation entries. |
-d |
Display the dynamic section. |
-V |
Display version information. |
-a |
Display all information (equivalent to -h -l -S -s -r -d -V ...). |
Examples
Display the ELF header of an executable
Shows the ELF header information for the ls executable.
Display section headers of a shared library
Displays the section headers of the C standard library.
Display the symbol table of an object file
Shows the symbol table, including defined and undefined symbols, for myprogram.o.
Display all information about an executable
Provides a comprehensive dump of all available ELF information for the bash executable.
Display dynamic section of a shared library
Shows the dynamic linking information for the pthreads library.