Keil Logo Arm Logo

Technical Support

On-Line Manuals

Linker User Guide

Conventions and feedback Overview of the linker Linking models supported by armlink Image structure and generation Using linker optimizations Getting information about images Accessing and managing symbols with armlink Using scatter files About scatter-loading When to use scatter-loading Scatter-loading command-line option Images with a simple memory map Images with a complex memory map Linker-defined symbols that are not defined when s Specifying stack and heap using the scatter file What is a root region? Creating root execution regions Using the FIXED attribute to create root regions Placing functions and data at specific addresses Placing a named section explicitly using scatter-l Placing unassigned sections with the .ANY module s Examples of using placement algorithms for .ANY se Example of next_fit algorithm showing behavior of Examples of using sorting algorithms for .ANY sect Selecting veneer input sections in scatter-loading Using __attribute__((section("name"))) t Using __at sections to place sections at a specifi Restrictions on placing __at sections Automatic placement of __at sections Manual placement of __at sections Placing a key in flash memory using __at Placing a structure over a peripheral register usi Placement of sections with overlays About placing ARM C and C++ library code 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 Reserving an empty region About creating regions on page boundaries Overalignment of execution regions and input secti Using preprocessing commands in a scatter file Expression evaluation in scatter files Using expression evaluation in a scatter file to a Equivalent scatter-loading descriptions for simple Type 1 image, one load region and contiguous execu Type 2 image, one load region and non-contiguous e Type 3 image, two load regions and non-contiguous Scatter file to ELF mapping

Placement of sections with overlays

Placement of sections with overlays

You can use the OVERLAY attribute in a scatter file to place multiple execution regions at the same address. An overlay manager is required to make sure that only one execution region is instantiated at a time. The ARM Compiler toolchain does not provide an overlay manager.

The following example shows the definition of a static section in RAM followed by a series of overlays. Here, only one of these sections is instantiated at a time.

Example 28. Specifying a root region

EMB_APP 0x8000			 
{
    .
    .
    STATIC_RAM 0x0                  ; contains most of the RW and ZI code/data
    {
            * (+RW,+ZI)
    }
    OVERLAY_A_RAM 0x1000 OVERLAY    ; start address of overlay...
    {
            module1.o (+RW,+ZI)
    }
    OVERLAY_B_RAM 0x1000 OVERLAY
    {
            module2.o (+RW,+ZI)
    }
    ...                             ; rest of scatter-loading description...
}

A region marked as OVERLAY is not initialized by the C library at startup. The contents of the memory used by the overlay region are the responsibility of an overlay manager. If the region contains initialized data, use the NOCOMPRESS attribute to prevent RW data compression.

The linker defined symbols can be used to obtain the addresses required to copy the code and data.

The OVERLAY attribute can be used on a single region that is not the same address as a different region. Therefore, an overlay region can be used as a method to prevent the initialization of particular regions by the C library startup code. As with any overlay region these must be manually initialized in your code.

An overlay region can have a relative base. The behavior of an overlay region with a +offset base address depends on the regions that precede it and the value of +offset. The linker places consecutive +offset regions at the same base address if they have the same +offset value.

When a +offset execution region ER follows a contiguous overlapping block of overlay execution regions the base address of ER is:

limit address of the overlapping block of overlay execution regions + offset

The following table shows the effect of +offset when used with the OVERLAY attribute. REGION1 appears immediately before REGION2 in the scatter file:

Table 16. Using relative offset in overlays

REGION1 is set with OVERLAY+offsetREGION2 Base Address
NO<offset>REGION1 Limit + <offset>
YES+0REGION1 Base Address
YES<none-zero offset>REGION1 Limit + <none-zero offset>

The following example shows the use of relative offsets with overlays and the effect on execution region addresses:

Example 29. Example of relative offset in overlays

EMB_APP 0x8000{
    CODE 0x8000
    {
        *(+RO)
    }

    # REGION1 Base = CODE limit
    REGION1 +0 OVERLAY
    {
        module1.o(*)
    }

    # REGION2 Base = REGION1 Base
    REGION2 +0 OVERLAY
    {
        module2.o(*)
    }

    # REGION3 Base = REGION2 Base = REGION1 Base
    REGION3 +0 OVERLAY
    {
        module3.o(*)
    }

    # REGION4 Base = REGION3 Limit + 4
    Region4 +4 OVERLAY
    {
        module4.o(*)
    }
}

If the length of the non-overlay area is unknown, a zero relative offset can be used to specify the start address of an overlay so that it is placed immediately after the end of the static section.

You can use the following command-line options to add extra debug information to the image:

  • --emit_debug_overlay_relocs

  • --emit_debug_overlay_section.

These permit an overlay-aware debugger to track which overlay is currently active.

Copyright © 2007-2008, 2011-2012 ARM. All rights reserved.ARM DUI 0377D
Non-ConfidentialID062912

Keil logo

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.