Quiz Entry - updated: 2026.07.14
What are the main sections in an ELF object file?
Code lives in .text, read-only data in .rodata, initialized globals in .data, uninitialized globals in .bss, plus the symbol table and relocation/debug sections.
* An ELF object opens with the header and closes with the section header table; the sections in between hold code, data, symbols and relocation info. *
| Section | Contents |
|---|---|
| .text | Machine code (executable instructions) |
| .rodata | Read-only data (string literals, jump tables) |
| .data | Initialized global and static variables |
| .bss | Uninitialized globals ("Block Started by Symbol") |
| .symtab | Symbol table (function and variable names) |
| .rel.text | Relocation info for .text section |
| .rel.data | Relocation info for .data section |
| .debug/.line | Debug information (with gcc -g) |
Important notes:
- .bss has a section header but occupies no space in the file - just records the size needed
- The ELF header comes first and describes file type, architecture, entry point
- Section header table at the end describes all sections
Tip: .bss saves disk space - why store thousands of zeros when you can just say "allocate N bytes of zeros"?
Go deeper:
Executable and Linkable Format (Wikipedia) — the ELF header, section and segment tables in detail.
elf(5) — the ELF format man page — the exact C structures for headers and sections.