Keil Logo

Technical Support

On-Line Manuals

Linker User Guide

Preface Overview of the Linker Linking Models Supported by armlink Image Structure and Generation Linker Optimization Features Getting Image Details Accessing and Managing Symbols with armlink Scatter-loading Features The scatter-loading mechanism Overview of scatter-loading When to use scatter-loading Linker-defined symbols that are not defined when s Specifying stack and heap using the scatter file Scatter-loading command-line options Scatter-loading images with a simple memory map Scatter-loading images with a complex memory map Scatter file with link to bit-band objects Root execution regions Root execution region and the initial entry point Root execution regions and the ABSOLUTE attribute Root execution regions and the FIXED attribute Methods of placing functions and data at specific Placement of code and data with __attribute__((sec Placement of __at sections at a specific address Restrictions on placing __at sections Automatic placement of __at sections Manual placement of __at sections Placement of a key in flash memory with an __at se Mapping a structure over a peripheral register wit Example of how to explicitly place a named section Placement of unassigned sections with the .ANY mod Placement rules when using multiple .ANY selectors Command-line options for controlling the placement Prioritization of .ANY sections Specify the maximum region size permitted for plac Examples of using placement algorithms for .ANY se Example of next_fit algorithm showing behavior of Examples of using sorting algorithms for .ANY sect Behavior when .ANY sections overflow because of li Placement of veneer input sections in a scatter fi Placement of sections with overlays Reserving an empty region Placement of ARM C and C++ library code Specifying ARM standard C and C++ libraries in a s Example of placing code in a root region Example of placing ARM C library code Example of placing ARM C++ library code Example of placing ARM library helper functions Creation of regions on page boundaries Overalignment of execution regions and input secti Preprocessing of a scatter file Example of using expression evaluation in a scatte Equivalent scatter-loading descriptions for simple Command-line options for creating simple images Type 1 image, one load region and contiguous execu Type 2 image, one load region and non-contiguous e Type 3 image, multiple load regions and non-contig How the linker resolves multiple matches when proc How the linker resolves path names when processing Scatter file to ELF mapping Scatter File Syntax Linker Command-line Options Linker Steering File Command Reference Via File Syntax

How the linker resolves multiple matches when processing scatter files

7.14 How the linker resolves multiple matches when processing scatter files

An input section must be unique. In the case of multiple matches, the linker attempts to assign the input section to a region based on the attributes of the input section description.

The linker assignment of the input section is based on a module_select_pattern and input_section_selector pair that is the most specific. However, if a unique match cannot be found, the linker faults the scatter-loading description.
The following variables describe how the linker matches multiple input sections:
  • m1 and m2 represent module selector patterns.
  • s1 and s2 represent input section selectors.
For example, if input section A matches m1,s1 for execution region R1, and A matches m2,s2 for execution region R2, the linker:
  • Assigns A to R1 if m1,s1 is more specific than m2,s2.
  • Assigns A to R2 if m2,s2 is more specific than m1,s1.
  • Diagnoses the scatter-loading description as faulty if m1,s1 is not more specific than m2,s2 and m2,s2 is not more specific than m1,s1.
armlink uses the following strategy to determine the most specific module_select_pattern, input_section_selector pair:
Resolving the priority of two module_selector, section_selector pairs m1, s1 and m2, s2
The strategy starts with two module_select_pattern, input_section_selector pairs. m1,s1 is more specific than m2,s2 only if any of the following are true:
  1. s1 is a literal input section name, that is it contains no pattern characters, and s2 matches input section attributes other than +ENTRY.
  2. m1 is more specific than m2.
  3. s1 is more specific than s2.
The conditions are tested in order so condition 1 takes precedence over condition 2 and 3, and condition 2 takes precedence over condition 3.
Resolving the priority of two module selectors m1 and m2 in isolation
For the module selector patterns, m1 is more specific than m2 if the text string m1 matches pattern m2 and the text string m2 does not match pattern m1.
Resolving the priority of two section selectors s1 and s2 in isolation
For the input section selectors:
  • If s1 and s2 are both patterns matching section names, the same definition as for module selector patterns is used.
  • If one of s1 or s2 matches the input section name and the other matches the input section attributes, s1 and s2 are unordered and the description is diagnosed as faulty.
  • If both s1 and s2 match input section attributes, the following relationships determine whether s1 is more specific than s2:
    • ENTRY is more specific than RO-CODE, RO-DATA, RW-CODE or RW-DATA.
    • RO-CODE is more specific than RO.
    • RO-DATA is more specific than RO.
    • RW-CODE is more specific than RW.
    • RW-DATA is more specific than RW.
    • There are no other members of the (s1 more specific than s2) relationship between section attributes.
This matching strategy has the following consequences:
  • Descriptions do not depend on the order they are written in the file.
  • Generally, the more specific the description of an object, the more specific the description of the input sections it contains.
  • The input_section_selectors are not examined unless:
    • Object selection is inconclusive.
    • One selector fully names an input section and the other selects by attribute. In this case, the explicit input section name is more specific than any attribute, other than ENTRY, that selects exactly one input section from one object. This is true even if the object selector associated with the input section name is less specific than that of the attribute.
The .ANY module selector is available to assign any sections that cannot be resolved from the scatter-loading description.

Example

The following example shows multiple execution regions and pattern matching:
LR_1 0x040000            
{                            
    ER_ROM 0x040000              ; The startup exec region address is the same
    {                            ; as the load address.  
        application.o (+ENTRY)   ; The section containing the entry point from
    }                            ; the object is placed here.
    ER_RAM1 0x048000      
    {
        application.o (+RO-CODE) ; Other RO code from the object goes here
    }
    ER_RAM2 0x050000     
    {
        application.o (+RO-DATA) ; The RO data goes here
    }
    ER_RAM3 0x060000 
    {
        application.o (+RW)      ; RW code and data go here
    }
    ER_RAM4 +0                   ; Follows on from end of ER_R3
    {
        *.o (+RO, +RW, +ZI)      ; Everything except for application.o goes here
    }
}
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.