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 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 are used to describe how the linker matches multiple input sections:

For example, if input section A matches m1,s1 for execution region R1, and A matches m2,s2 for execution region R2, the linker:

armlink uses the following sequence to determine the most specific module_select_pattern, input_section_selector pair:

  1. 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.

  2. 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, 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 determination of whether s1 is more specific than s2 is defined by the relationships below:

      • 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.

  3. For the module_select_pattern, input_section_selector pair, 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 a takes precedence over condition b and c, and condition b takes precedence over condition c.

This matching strategy has the following consequences:

The .ANY module selector is available to assign any sections that cannot be resolved from the scatter-loading description.

The following example shows multiple execution regions and pattern matching:

Example 8. 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
    }
}

Show/hideSee also

Copyright © 2008, 2011-2012 ARM. All rights reserved.ARM DUI 0458C
Non-ConfidentialID062912