10.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 banks. 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.

  • .pbss - These sections are used to store variables which use the persistent attribute, whose values should not be altered by the runtime start-up code. They are not cleared or otherwise modified at start-up.
  • .bss - These sections (also .sbss) 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 - These sections (also .sdata) 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.