TATVONYour account ↗
Embedded C / 18 MIN

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.

01

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.

02

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.

03

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; }
SEE THE SYSTEM

Follow each transition

1 / 4
STEP 1

Flash image

Instructions and initial values are in the image.

Conceptual sequence. Timing is slowed for learning; it is not a hardware measurement.

PUT IT TO WORK

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
  1. Locate the symbol's load and runtime addresses.
  2. Inspect the copy table and startup loop.
  3. Check that main is entered after initialization.
  4. Exclude a later write using a data breakpoint.
CHECK YOUR UNDERSTANDING

Which statement about a static local is correct?

Choose one answer
Sign up to save your progress →

Answer the knowledge check correctly to complete this lesson.

TATVON AI MENTOR

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…