Linkers, Loaders & Executables
What is a characteristic of the .bss section?
- AIt is where local variables are placed each time a function is called
- BIt holds variables with no initializer (or zero); the file records only its size, and it is zero-filled at load time
- 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.