4.4.2.1.2 Changing the Default Allocation

You can change the default memory allocation of objects with static storage duration by either:

  • Using specifiers
  • Making the objects absolute
  • Placing objects in their own section and explicitly linking that section

Variables can be placed in a combined flash and data section by using the __memx specifier (see 4.3.9.1 Memx Address Space Qualifier).

If only a few objects are to be located at specific addresses in data space memory, then those objects can be made absolute (described in 4.4.4 Absolute Variables). Once variables are made absolute, their address is hard coded in generated output code, they are no longer placed in a section and do not follow the normal memory allocation procedure.

The .bss and .data sections, in which the different categories of static storage duration objects are allocated, can be shifted as a whole by changing the default linker options. For example, you could move all the persistent variables.

Objects can also be placed at specific positions by using the __section() specifier (see 4.3.10.10 Section Attribute) after enabling the CCI (see 3.6.3.4 Ext Option) to allocate them to a unique section, then link that section to the required address via an option. See 4.14.2 Changing and Linking the Allocated Section for more information on changing the default linker options for sections.