Linkers, Loaders & Executables

What is a characteristic of the .bss section?

  1. AIt is where local variables are placed each time a function is called
  2. BIt holds variables with no initializer (or zero); the file records only its size, and it is zero-filled at load time
  3. CIt is a read-only area for constant strings
Show answer and explanation

Answer: B. It holds variables with no initializer (or zero); the file records only its size, and it is zero-filled at load time

Global and static variables without an initializer start at zero by the rules of C. Storing a run of zeros in the file would be wasteful, so the .bss section records only its size, and the loader allocates and zero-fills the memory. For example, "static char buf[1000000];" does not make the executable 1 MB larger.

  • A. Locals go on the stack.
  • B. Correct. It saves file size.
  • C. Constants go in .rodata.
Practice this topic Back to topic

More Linkers, Loaders & Executables questions

  1. Running C code "char *p = "hello"; p[0] = 'H';" crashes in many environments. Why?
  2. Of the global variables above, which are generally placed in the .bss section?
  3. Where is a non-static local (automatic) variable declared inside a C function placed at run time?
  4. Memory allocated with C's malloc generally comes from which area of a process?
  5. Which lists the typical memory layout of a process on Linux and similar systems from low to high addresses?