| |||||||||||||||||||||||||||||
Technical Support On-Line Manuals RealView Linker and Utilities Guide | Expression evaluation in scatter-loading files
Scatter files frequently contain numeric constants that are specified as expressions. The linker also provides an assertion function called Expressions can be used in the following places:
Expressions follow the C-Precedence rules and are made up of the following:
All operators match their C counterparts in meaning and precedence. Expressions are not case sensitive and parentheses can be used for clarity. The execution address related functions can only be used when specifying a Table 5.2. Execution address related functions
See Table 4.1 for more information on region-related linker symbols. The parameter The The load address related functions can only be used within the Table 5.3. Load address related functions
The parameter The symbol related function, Example 5.3. Specifying the maximum size in terms of an expression
LR1 0x8000 (2 * 1024)
{
ER1 +0 (1 * 1024)
{
*(+RO)
}
ER2 +0 (1 * 1024)
{
*(+RW +ZI)
}
}
Example 5.4. Placing an execution region after another
LR1 0x8000
{
ER1 0x100000
{
*+RO
}
}
LR2 0x100000
{
ER2 (ImageLimit(ER1)) ; Place ER2 after ER1 has finished
{
*(+RW +ZI)
}
}
Example 5.5. Conditionalizing a base address based on the presence of a symbol
LR1 0x8000
{
ER1 (defined(version1) ? 0x8000 : 0x10000) ; Base address is 0x8000
; if version1 is defined
; 0x10000 if not
{
*(+RO)
}
ER2 +0
{
*(+RW +ZI)
}
}
A combination of pre-processor macros and expressions is used in Example 5.6 to copy tightly packed execution regions to execution addresses in a page-boundary. Using the Example 5.6. Aligning a base address in execution space but still tightly packed in load space
#! armcc -E
#DEFINE START_ADDRESS 0x100000
#DEFINE PAGE_ALIGNMENT 0x100000
#DEFINE MY_ALIGN(address, alignment) ((address +
(alignment-1)) AND ~(alignment-1))
LR1 0x8000
{
ER0 +0
{
*(InRoot$$Sections)
}
ER1 START_ADDRESS
{
file1.o(*)
}
ER2 MY_ALIGN(ImageLimit(ER1), PAGE_ALIGNMENT)
{
file2.o(*)
}
ER3 MY_ALIGN(ImageLimit(ER2), PAGE_ALIGNMENT)
{
file3.o(*)
}
}
Example 5.7. Using ScatterAssert to check the size of multiple regions
LR1 0x8000
{
ER0 +0
{
*(+RO)
}
ER1 +0
{
file1.o(+RW)
}
ER2 +0
{
file2.o(+RW)
}
ScatterAssert((LoadLength(ER1) + LoadLength(ER2)) < 0x1000)
; LoadLength is compressed size
ScatterAssert((ImageLength(ER1) + ImageLength(ER2)) < 0x2000)
; ImageLength is uncompressed size
}
ScatterAssert(ImageLength(LR1) < 0x3000) ; Check uncompressed size of LoadRegion
| ||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||