LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the .bss section and why does it exist?

.bss holds uninitialized (zero) globals and statics; it takes no space in the file — just a recorded size — and the loader zero-fills it in memory.

.bss on disk records only its size (~0 bytes) while .data stores actual bytes; at load the loader copies .data and allocates plus zero-fills .bss

* .data carries real bytes on disk; .bss carries only a size — the loader materialises its zeros in memory at startup. *

// Goes in .data
int initialized = 42;
// Goes in .bss
int uninitialized;
// Goes in .bss
static int also_bss;

Why have a separate section?

The .bss section occupies no space in the object file - only the section header records how much memory is needed.

Section In file In memory
.data Yes (actual bytes) Yes
.bss No (just size) Yes (zeroed)

Space savings example:

char buffer[1000000];  // 1MB uninitialized
// In .bss: adds ~0 bytes to file
// In memory: 1MB of zeros allocated at load time

The loader:

  1. Reads .bss size from section header
  2. Allocates that much memory
  3. Fills it with zeros

Tip: This is why uninitialized globals are guaranteed to be zero in C - the OS zeros the .bss pages.

Go deeper:

  • chart .bss (Wikipedia) — the section that stores a size, not the zeros themselves.

From Quiz: REVE1 / Program Execution | Updated: Jul 14, 2026