Where things live in a C program: .text, .rodata, .data, .bss, stack
A compiled C program is an ELF file split into sections. The loader maps them into memory with different permissions, and those permissions are what the CPU enforces at runtime. Section Holds Permissions Example .text machine code read + execute main .rodata read-only data read (no write) string literals, static const tables .data initialized globals / statics read + write static char buf[] = "hi"; .bss zero-initialized globals / statics read + write static int counter; stack locals, return addresses read + write char buf[8]; inside a function .data and .rodata are both in the binary; “in the binary” doesn’t mean read-only. The section decides that. .bss takes no space in the file (type NOBITS): the loader just hands out zeroed memory. Writing to .rodata (e.g. through a pointer to a string literal) → the page isn’t writable → SIGSEGV. See it yourself Sections and their flags (A = alloc, W = write, X = exec): ...