SLAU131V October 2004 – February 2020
The linker allocates output sections from low to high addresses within a designated memory range by default. Alternatively, you can cause the linker to allocate a section from high to low addresses within a memory range by using the HIGH location specifier in the SECTION directive declaration. You might use the HIGH location specifier in order to keep RTS code separate from application code, so that small changes in the application do not cause large changes to the memory map.
For example, given this MEMORY directive:
MEMORY
{
RAM : origin = 0x0200, length = 0x0800
FLASH : origin = 0x1100, length = 0xEEE0
VECTORS : origin = 0xFFE0, length = 0x001E
RESET : origin = 0xFFFE, length = 0x0002
}
and an accompanying SECTIONS directive:
SECTIONS
{
.bss : {} > RAM
.sysmem : {} > RAM
.stack : {} > RAM (HIGH)
}
The HIGH specifier used on the .stack section placement causes the linker to attempt to allocate .stack into the higher addresses within the RAM memory range. The .bss and .sysmem sections are allocated into the lower addresses within RAM. Example 6 illustrates a portion of a map file that shows where the given sections are allocated within RAM for a typical program.