$linuxjunkies
>

readelf(1)

Display information about ELF object files, including headers, sections, symbols, and relocations.

UbuntuDebianFedoraArch

Synopsis

readelf [OPTION]... FILE...

Description

readelf displays detailed information from ELF (Executable and Linkable Format) object files, shared libraries, and executables. It reads and parses the ELF file structure to show headers, sections, symbols, relocations, and other binary metadata without executing the file.

Unlike objdump, readelf focuses on structural information and is particularly useful for debugging, reverse engineering, and understanding binary dependencies and symbol tables.

Common options

FlagWhat it does
-h, --file-headerDisplay the ELF file header
-l, --program-headersDisplay the program headers (segments)
-S, --section-headersDisplay the section headers table
-s, --syms, --symbolsDisplay the symbol table entries
-r, --relocsDisplay the relocation entries
-d, --dynamicDisplay the dynamic section (for shared objects and executables)
-e, --headersDisplay all headers (file, program, and section)
-a, --allDisplay all information (equivalent to -e -l -S -s -r -d)
-x, --hex-dump=<number|name>Hex dump of section by number or name
-p, --string-dump=<number|name>String dump of section (printable characters only)
-V, --version-infoDisplay version symbol section
-w, --debug-dump=[rawline,=info,=loc,...]Display DWARF debug information

Examples

Show the ELF file header of the bash binary, including magic number, architecture, and entry point

readelf -h /bin/bash

List all sections in the C library, useful for understanding binary structure

readelf -S /usr/lib/libc.so.6 | head -20

Display all function and object symbols in the ls command

readelf -s /bin/ls | grep 'FUNC\|OBJECT'

Show all shared library dependencies of a binary

readelf -d /usr/bin/python3 | grep NEEDED

Hex dump the .comment section to see compiler information

readelf -x .comment /bin/cat

Find the dynamic linker path for an executable

readelf -l /bin/dd | grep 'INTERP'

Display relocation entries for a shared library

readelf -r /usr/lib/libssl.so.1.1 | head -15

Display all headers of a custom binary and page through the output

readelf -e ./myprogram 2>&1 | less

Related commands