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
boundary in both the
load and the execution view. To align in the load view, the linker must insert 0x8000
bytes of padding.0x4000
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
boundary. This creates an
execution region with a load address of 0x8000
but an Execution Address of 0x4000
.0x8000