Quiz Entry - updated: 2026.07.10
How do you analyze an ELF file using readelf?
Run readelf with the flag for what you want: -a (everything), -s (symbol table), -S (section headers), -r (relocations).
# Print ALL information
$ readelf -a file.o
# Print SYMBOL table
$ readelf -s file.o
# Print SECTION headers
$ readelf -S file.o
# Print RELOCATION info
$ readelf -r file.o
Example symbol table output:
Num: Size Type Bind Ndx Name
9: 8 OBJECT GLOBAL 3 buf
10: 83 FUNC GLOBAL 1 main
13: 0 NOTYPE GLOBAL UND swap
Key fields:
- Type: OBJECT (data), FUNC (code), NOTYPE (undefined)
- Bind: GLOBAL (visible outside), LOCAL (file-private)
- Ndx: Section index (1=.text, 3=.data, UND=undefined)
UND = Undefined: The symbol is referenced but defined elsewhere - the linker must find it.
Go deeper:
readelf(1) man page — every flag (
-a,-s,-S,-r) and what each dump means.elf(5) — the ELF format man page — how to read the symbol-table fields readelf prints.