- IAR Embedded Workbench for Arm 9.70.x
- IAR C/C++ Development
- The linker configuration file
- Using symbols, expressions, and numbers
- Expressions in linker configuration files
Expressions in linker configuration files
Syntax
An expression is built up of the following constituents:
expressionbinopexpressionunop expressionexpression?expression:expression(expression)numbersymbolfunc-operator
where binop is one of these binary operators:
+, -, *, /, %, <<, >>, <, >, ==, !=, &, ^, |, &&, ||
where unop is one of these unary operators:
+, -, !, ~
where number is a number, see Numbers in linker configuration files
where symbol is a defined symbol, see define symbol directive and ‑‑config_def
and where func-operator is one of these function-like operators, available in all expressions:
| The value of |
| The value of |
| The highest address in the region. |
| True ( |
| True ( |
| The largest of the parameters. |
| The smallest of the parameters. |
| The total size of all ranges in the region. |
| True ( |
| The lowest address in the region. |
where align and expr are expressions, and region is a region expression, see Region expression.
Note that isdefinedsymbol allows you to probe the linker context without giving an error if something is not there. In combination with if conditions, this can lead to unexpected results. The if evaluation order specifies that any conditions that rely on isdefinedsymbol—either directly or indirectly through other symbols—are evaluated last. Specifically, all if conditions that do not rely on isdefinedsymbol and can be evaluated are processed first. Once those are complete, any remaining if conditions that do rely on isdefinedsymbol (and can otherwise be evaluated) are evaluated in the same context.
Consider this example:
if((x > 0) && !isdefinedsymbol(y))
{
define symbol z = 1;
}
if((x > 0) && !isdefinedsymbol(z))
{
define symbol y = 1;
}
if(!isdefinedsymbol(w))
{
define symbol x = 1;
}In this example, the two first conditions cannot be evaluated, because x does not have a well-defined value. The only condition that can be evaluated is !isdefinedsymbol(w), which is true, so x=1 is added to the context. Then the other two conditions—(x > 0) && !isdefinedsymbol(y) and (x > 0) && !isdefinedsymbol(z)—are evaluated in the same context. Both are true, so z=1,y=1 are added to the context.
func-operator can also be one of these operators, which are only available in expressions for the size or alignment of a block or overlay, in check that expressions, and in data expressions in define section directives:
| If |
| The alignment of the thread-local storage area. |
| The size of the thread-local storage area. |
Description
In the linker configuration file, an expression is a 65-bit value with the range -2^64 to 2^64. The expression syntax closely follows C syntax with some minor exceptions. There are no assignments, casts, pre or post-operations, and no address operations (*, &, [], ->, and .). Some operations that extract a value from a region expression, etc, use a syntax resembling that of a function call. A boolean expression returns 0 (False) or 1 (True).