7.12 Example of using expression evaluation in a scatter file to avoid padding

This example shows how to use expression evaluation in a scatter file to avoid padding.

Using certain scatter-loading attributes in a scatter file can result in a large amount of padding in the image.

To remove the padding caused by the ALIGN, ALIGNALL, and FIXED attributes, use expression evaluation to specify the start address of a load region and execution region. The built-in function AlignExpr is available to help you specify address expressions.

Example

The following scatter file produces an image with padding:

LR1 0x4000
{
    ER1 +0 ALIGN 0x8000
    {
        …
    }
}

In this example, the ALIGN keyword causes ER1 to be aligned to a 0x8000 boundary in both the load and the execution view. To align in the load view, the linker must insert 0x4000 bytes of padding.

The following scatter file produces an image without padding:

LR1 0x4000
{
    ER1 AlignExpr(+0, 0x8000)
    {
        …
    }
}

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.

Non-ConfidentialPDF file icon PDF versionARM DUI0474M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.