LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the purpose of the .text, .data, .rodata, and .bss sections?

Programs are split into sections by content type so the OS can give each the right permissions — code read-only and executable, constants read-only, variables writable.

Program sections colour-coded by their memory permissions.

* Each section gets the permissions it needs: code read-only and executable, constants read-only, globals writable; .bss takes no disk space. *

Separating sections is both a security and an efficiency measure: code never needs to be writable, and uninitialized data needn't occupy space in the file.

Section Contents Characteristics
.text Machine code Read-only, executable
.rodata Constants, string literals Read-only, non-executable
.data Initialized globals Read-write, non-executable
.bss Uninitialized globals Read-write, zero-filled, takes no file space
int initialized = 42;        // .data
const char *msg = "hello";   // pointer in .data, string in .rodata
int uninitialized;           // .bss
void func() { }              // .text

Why it pays off:

  • Security: keeping .text read-only-and-executable (and data non-executable) blocks whole classes of exploits.
  • Memory: .bss records only a size, not bytes, so a big zero-initialized array costs nothing on disk.
  • Sharing: read-only .text/.rodata can be shared between processes.

Inspect them with objdump -h program or readelf -S program.

Go deeper:

From Quiz: REVE1 / The Processor Interface | Updated: Jul 14, 2026