10.2 Linker Allocation

Linker allocation is controlled by the linker script, and proceeds in three steps:

  1. Mapping Input Sections to Output Sections.
  2. Assigning Output Sections to Regions.
  3. Allocating Unmapped Sections.

Steps 1 and 2 are performed by a sequential memory allocator. Input sections which appear in the linker script are assigned to specific memory regions in the target devices. Addresses within a memory region are allocated sequentially, beginning with the lowest address and growing upwards.

Step 3 is performed by a best-fit memory allocator. Input sections which do not appear in the linker script are assigned to memory regions according to their attributes. The best-fit allocator makes efficient use of any remaining memory, including gaps between output sections that may have been left by the sequential allocator.