9.2.1 Non-auto Variable Allocation
Non-auto
variables (those with permanent storage
duration) are located by the compiler into any of the available data memory. This is done
in a two-stage process: placing each variable into an appropriate section and later linking
that section into data memory.
The compiler considers three categories of non-auto
variable which all relate to the value the variable should contain by the time the program
begins. The following sections are used for the categories described.
.bss
This section contain any uninitialized variables, which are not assigned a value when they are defined, or variables which should be cleared by the runtime start-up code..data
This section contain the RAM image of any initialized variables, which are assigned a non-zero initial value when they are defined and which must have a value copied to them by the runtime start-up code.
Note that the data section used to hold initialized variables is the
section that holds the RAM variables themselves. There is a corresponding section (called
.dinit
) that is placed into program memory (so it is non-volatile) and
which is used to hold the initial values that are copied to the RAM variables by the
runtime start-up code.