Linker Script Language (LSL)
14.2.4. Expressions
The expressions and operators in this section work the same as in ISO C.
number ::= OCT_NUM
| DEC_NUM
| HEX_NUM
expr ::= number
| symbol_name
| unary_op expr
| expr binary_op expr
| expr ? expr : expr
| ( expr )
| function_call
unary_op ::= ! // logical NOT
| ~ // bitwise complement
| - // negative value
binary_op ::= ^ // exclusive OR
| * // multiplication
| / // division
| % // modulus
| + // addition
| - // subtraction
| >> // right shift
| << // left shift
| == // equal to
| != // not equal to
| > // greater than
| < // less than
| >= // greater than or equal to
| <= // less than or equal to
| & // bitwise AND
| | // bitwise OR
| && // logical AND
| || // logical OR
14.2.5. Built-in Functions
function_call ::= absolute ( expr )
| addressof ( addr_id )
| exists ( section_name )
| max ( expr , expr )
| min ( expr , expr )
| sizeof ( size_id )
addr_id ::= sect : section_name
| group : group_name
749
TASKING VX-toolset for TriCore User Guide
size_id ::= sect : section_name
| group : group_name
| mem : mem_name
• Every space, bus, memory, section or group your refer to, must be defined in the LSL file.
• The addressof()
and sizeof()
functions with the
group
or
sect
argument can only be used in the right hand side of an assignment. The sizeof()
function with the
mem
argument can be used anywhere in section layouts.
You can use the following built-in functions in expressions. All functions return a numerical value. This value is a 64-bit signed integer.
absolute()
int absolute( expr )
Converts the value of expr to a positive integer.
absolute( "labelA"-"labelB" )
addressof()
int addressof( addr_id )
Returns the address of addr_id, which is a named section or group. To get the offset of the section with the name asect
: addressof( sect: "asect")
This function only works in assignments.
exists()
int exists( section_name )
The function returns 1 if the section section_name exists in one or more object file, 0 otherwise. If the section is not present in input object files, but generated from LSL, the result of this function is undefined.
To check whether the section mysection
exists in one of the object files that is specified to the linker: exists( "mysection" )
max()
int max( expr, expr )
Returns the value of the expression that has the largest value. To get the highest value of two symbols: max( "sym1" , "sym2")
750