9.5.3.1 Simple Assignments
symbol = expression ;
symbol += expression ;
symbol -= expression ;
symbol *= expression ;
symbol /= expression ;
symbol <<= expression ;
symbol >>= expression ;
symbol &= expression ;
symbol |= expression ;
The first of the above examples will define
symbol
to have the value of
expression
. In the other examples,
symbol
must already be defined, and the value will be
adjusted according to the results of the operation.
The special symbol name (.
) indicates the location
counter. This symbol may be only used within a SECTIONS
command.
The semicolon after expression is required.
Expressions are defined in 9.6 Expressions in Linker Scripts.
Symbol assignments may appear as commands in their own right, or as statements within a SECTIONS
command, or as part of an output section description in a SECTIONS
command.
The section of the symbol will be set from the section of the expression; for more information, see 9.6.6 The Section of an Expression.
floating_point = 0;
SECTIONS
{
.text ORIGIN(kseg0_program_mem) :
{
_text_begin = . ;
*(.text .stub .text.* )
_text_end = . ;
} >kseg0_program_mem =0
_bdata = (. + 3) & ~ 3;
.data : { *(.data) }
}
In this example, the symbol floating_point
will be defined as zero. The symbol _text_end
will be defined as the address following the last .text
input section. The symbol _bdata
will be defined as the address following the .text
output section aligned upward to a 4-byte boundary.