Where does your C data live?
Trace a declaration from the executable image to RAM. Storage duration and initialization explain more than memorising section names.
Load image and runtime address
On a typical MCU, executable instructions and read-only data are stored in Flash. Writable initialized globals occupy RAM at runtime, with initial bytes held in the load image. The linker script and startup code define the exact arrangement; C itself does not require sections named .data or .bss.
What startup does
Before main, startup normally copies initialized writable data into RAM and clears zero-initialized static storage. A nonzero initializer usually needs image bytes; a zero-initialized object can be represented by a size to clear. Retained or no-init regions are deliberate exceptions requiring their own validity rules.
Automatic objects
A local automatic object has block-related lifetime. It may use the stack, registers, or be optimized away. A static local has static storage duration even though its name has local scope. Never return the address of an automatic local that has stopped existing.
const unsigned limits[2] = {10, 20};
unsigned mode = 3;
static unsigned errors;
void task(void) { unsigned sample = mode; }Follow each transition
Flash image
Instructions and initial values are in the image.
Conceptual sequence. Timing is slowed for learning; it is not a hardware measurement.
Your investigation
Your global mode is 3 in the map file's load image but 0 at the first application instruction. Which startup evidence would you collect?
Reveal the investigation checklist
- Locate the symbol's load and runtime addresses.
- Inspect the copy table and startup loop.
- Check that main is entered after initialization.
- Exclude a later write using a data breakpoint.
Which statement about a static local is correct?
Answer the knowledge check correctly to complete this lesson.
Think through Where does your C data live?
Ask for an explanation, an automotive example or a question that tests your understanding.
Checking mentor availability…