5.3.4. Using overlays to place sections
You can use the OVERLAY attribute in a scatter-loading description file to place multiple execution regions at the same address. Example 5.18 defines a static section in RAM followed by a series of overlays. Here, only one of these sections is instantiated at runtime.
Example 5.18. 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 description...
}
If the length of the static area is unknown, use a zero relative offset to specify the start address of an overlay so that it is placed immediately after the end of the static section, for example:
OVERLAY_A_RAM +0 OVERLAY
In this case, consecutive overlay regions with the same +offset are placed at +offset bytes from the previous non-overlay region or start of load region. Do this to avoid unused RAM (where the static area is small) or to prevent overwriting the static area with an overlay (where the static area is large).