๐ WAYPOINT LESSON
Sections and Their Contents
โญโญโญ advancedโณ 16 min read๐ Lesson 184 of 225
What .text, .data, .bss, and .rodata actually hold โ verified with size and nm on a live binary.
Every byte of a program lives in a section
- .text โ executable code. Read-only at runtime; self-modifying it is UB and modern kernels enforce it.
- .data โ initialized globals (
int x = 5;). Occupies file space. - .bss โ zero-initialized globals (
int y;). Occupies no file space: the loader simply zeroes pages at load. A million-bytestatic char big[1000000];costs nothing on disk. - .rodata โ string literals and const data. Your
"hello"literals live here; writing to them is the UB from module 2.
size a.out prints the totals; nm a.out lists which symbol landed where (the T/D/B letters from module 10).
Relocation: why .o files are not runnable
An object file's calls and global references are placeholders โ the final addresses do not exist until the linker lays sections out. Relocation entries record 'patch this byte sequence with the address of that symbol'. That is why linking two objects fixes what compiling them separately could not.
โก Now practice
Ready to CodeBinary Forensics DrillsDrive gcc, ar, nm, and size inside the sandbox: compile objects, build archives, resolve symbols โ the linker as a lab instrument.
4 challenges ยท ยท ~24 min