Thursday, August 15, 2013

Execution address built-in functions for use in scatter files

Source: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0493c/CHDJDHFI.html

Execution address built-in functions for use in scatter files

The execution address related functions can only be used when specifying a base_address+offsetvalue, or max_size. They map to combinations of the linker defined symbols shown in Table 4.
Table 4. Execution address related functions 
FunctionLinker defined symbol value
ImageBase(region_name)
Image$$region_name$$Base
ImageLength(region_name)
Image$$region_name$$Length + Image$$region_name$$ZI$$Length
ImageLimit(region_name)
Image$$region_name$$Base + Image$$region_name$$Length + Image$$region_name$$ZI$$Length

The parameter region_name  can be either a load or an execution region name. Forward references are not permitted. The region_name can only refer to load or execution regions that have already been defined.

Note

You cannot use these functions when using the .ANY selector pattern. This is because a .ANYregion uses the maximum size when assigning sections. The maximum size might not be available at that point, because the size of all regions is not known until after the .ANY assignment.
The following example shows how to use ImageLimit(region_name) to place one execution region immediately after another:
Example 10. Placing an execution region after another
LR1 0x8000
{
    ER1 0x100000
    {
        *(+RO)
    }
}
LR2 0x100000
{
    ER2 (ImageLimit(ER1))               ; Place ER2 after ER1 has finished
    {
        *(+RW +ZI)
    }
}

Show/hideUsing +offset with expressions

+offset value for an execution region is defined in terms of the previous region. You can use this as an input to other expressions such as AlignExpr. For example:
LR1 0x4000
{
    ER1 AlignExpr(+0, 0x8000)
    {
        ...
    }
}
By using AlignExpr, the result of +0 is aligned to a 0x8000 boundary. This creates an execution region with a load address of 0x4000 but an execution address of 0x8000.