8.7 Scatter files containing relative base address load regions and a ZI execution region

You might want to place zero-initialized (ZI) data in one load region, and use a relative base address for the next load region.

To place ZI data in load region LR1, and use a relative base address for the next load region LR2, for example:
LR1 0x8000
{
    er_progbits +0
    {
        *(+RO,+RW) ; Takes space in the Load Region
    }
    er_zi +0
    {
        *(+ZI) ; Takes no space in the Load Region
    }
}
LR2 +0 ; Load Region follows immediately from LR1
{
    er_moreprogbits +0
    {
        file1.o(+RO) ; Takes space in the Load Region
    }
}
Because the linker does not adjust the base address of LR2 to account for ZI data, the execution region er_zi overlaps the execution region er_moreprogbits. This generates an error when linking.
To correct this, use the ImageLimit() function with the name of the ZI execution region to calculate the base address of LR2. For example:
LR1 0x8000
{
    er_progbits +0
    {
        *(+RO,+RW) ; Takes space in the Load Region
    }
    er_zi +0
    {
        *(+ZI) ; Takes no space in the Load Region
    }
}
LR2 ImageLimit(er_zi) ; Set the address of LR2 to limit of er_zi
{
    er_moreprogbits +0
    {
        file1.o(+RO) ; Takes space in the Load Region
    }
}
Related concepts
8.6 Expression evaluation in scatter files
8.6.3 Expression usage in scatter files
8.6.4 Expression rules in scatter files
8.6.5 Execution address built-in functions for use in scatter files
Related reference
8.2 Syntax of a scatter file
8.3.2 Syntax of a load region description
8.4.2 Syntax of an execution region description
6.3.2 Image$$ execution region symbols
Non-ConfidentialPDF file icon PDF versionARM DUI0377G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.