You copied the Doc URL to your clipboard.

Section placement with the linker

By default, the linker places input sections in the following order when generating an image:

  1. By attribute as follows:

    1. read-only code.

    2. read-only data.

    3. read-write code.

    4. read-write data.

    5. zero-initialized data.

  2. By input section name if they have the same attributes. Names are considered to be case-sensitive and are compared in alphabetical order using the ASCII collation sequence for characters.

  3. By their relative positions in the input file if they have the same attributes and section names, except where overridden by FIRST or LAST.

Portions of the image are collected together into a minimum number of contiguous regions.


The sorting order is unaffected by ordering within scatter files or object file names.

These rules mean that the positions of input sections with identical attributes and names included from libraries is not predictable. If you require more precise positioning, specify the individual modules explicitly in a scatter file, and include the modules in the input file list for the armlink command.

The base address of each input section is determined by the sorting order defined by the linker, and is correctly aligned within the output section that contains it.

By default, the linker creates an image consisting of an RO output section, an RW output section, and optionally a ZI output section. The RO output section can be protected at run-time on systems that have memory management hardware. RO sections can also be placed into ROM in the target.

Alternative sorting orders are available with the --sort=algorithm command-line option. The linker might change the algorithm to minimise the amount of veneers generated if no algorithm is chosen.

Handling unassigned sections

The linker might not be able to place some input sections in any execution region. When this happens, the linker generates an error message. This might occur because your current scatter file does not permit all possible module select patterns and input section selectors. How you fix this depends on the importance of placing these sections correctly:

  • If the sections must be placed at specific locations, then modify your scatter file to include specific module selectors and input section selectors as required.

  • If the placement of the unassigned sections is not important, you can use one or more ,ANY module selectors with optional input section selectors.

When the linker creates an input section for each ELF section in the input objects, it increments a global counter. The value of this counter is stored in the section as the creation index. The creation index is used when placing any unassigned sections that have identical properties.


The following scatter file shows how the linker places sections:

LoadRegion 0x8000
    ExecRegion1 0x0000 0x4000
    ExecRegion2 0x4000 0x2000

The order of execution regions within the load region is not altered by the linker.