Keil Logo

Technical Support

On-Line Manuals

Linker User Guide

Preface Overview of the Linker Linking Models Supported by armlink Image Structure and Generation The structure of an ARM ELF image Views of the image at each link stage Input sections, output sections, regions, and prog Load view and execution view of an image Methods of specifying an image memory map with the Image entry points Simple images Types of simple image Type 1 image structure, one load region and contig Type 2 image structure, one load region and non-co Type 3 image structure, multiple load regions and Section placement with the linker Default section placement Section placement with the FIRST and LAST attribut Section alignment with the linker Linker support for creating demand-paged files Linker reordering of execution regions containing Linker-generated veneers What is a veneer? Veneer sharing Veneer types Generation of position independent to absolute ven Reuse of veneers when scatter-loading Command-line options used to control the generatio Weak references and definitions How the linker performs library searching, selecti How the linker searches for the ARM standard libra Specifying user libraries when linking How the linker resolves references The strict family of linker options Linker Optimization Features Getting Image Details Accessing and Managing Symbols with armlink Scatter-loading Features Scatter File Syntax Linker Command-line Options Linker Steering File Command Reference Via File Syntax

Default section placement

3.3.1 Default section placement

By default, the linker places input sections in a specific order within an execution region.

The sections are placed in the following order:
  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 a tie-breaker if they have the same attributes and section names. By default, it is the order that armlink processes the section. You can override the tie-breaker and sorting by input section name with the FIRST or LAST input section attribute.


The sorting order is unaffected by ordering of section selectors within execution regions.
These rules mean that the positions of input sections with identical attributes and names included from libraries depend on the order the linker processes objects. This can be difficult to predict when many libraries are present on the command line. The --tiebreaker=cmdline option uses a more predictable order based on the order the section appears on the command line.
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.
The linker produces one output section for each attribute present in the execution region:
  • One execute-only (XO) section if the execution region contains only XO sections.
  • One RO section if the execution region contains read-only code or data.
  • One RW section if the execution region contains read-write code or data.
  • One ZI section if the execution region contains zero-initialized data.


If an attempt is made to place data in an XO only execution region, then the linker generates an error.
XO sections lose the XO property if mixed with RO code in the same Execution region.
The XO and RO output sections can be protected at run-time on systems that have memory management hardware. RO and XO sections can be placed in ROM or Flash.
Alternative sorting orders are available with the --sort=algorithm command-line option. The linker might change the algorithm to minimize the amount of veneers generated if no algorithm is chosen.


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.

Handling unassigned sections

The linker might not be able to place some input sections in any execution region.

When the linker is unable to place some input sections it 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.
Non-ConfidentialPDF file icon PDF versionARM DUI0377H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.