ld: Simple Assignments
1
1 3.5.1 Simple Assignments
1 ------------------------
1
1 You may assign to a symbol using any of the C assignment operators:
1
1 'SYMBOL = EXPRESSION ;'
1 'SYMBOL += EXPRESSION ;'
1 'SYMBOL -= EXPRESSION ;'
1 'SYMBOL *= EXPRESSION ;'
1 'SYMBOL /= EXPRESSION ;'
1 'SYMBOL <<= EXPRESSION ;'
1 'SYMBOL >>= EXPRESSION ;'
1 'SYMBOL &= EXPRESSION ;'
1 'SYMBOL |= EXPRESSION ;'
1
1 The first case will define SYMBOL to the value of EXPRESSION. In the
1 other cases, SYMBOL must already be defined, and the value will be
1 adjusted accordingly.
1
1 The special symbol name '.' indicates the location counter. You may
1 only use this within a 'SECTIONS' command. ⇒Location Counter.
1
1 The semicolon after EXPRESSION is required.
1
1 Expressions are defined below; see ⇒Expressions.
1
1 You may write symbol assignments as commands in their own right, or
1 as statements within a 'SECTIONS' command, or as part of an output
1 section description in a 'SECTIONS' command.
1
1 The section of the symbol will be set from the section of the
1 expression; for more information, see ⇒Expression Section.
1
1 Here is an example showing the three different places that symbol
1 assignments may be used:
1
1 floating_point = 0;
1 SECTIONS
1 {
1 .text :
1 {
1 *(.text)
1 _etext = .;
1 }
1 _bdata = (. + 3) & ~ 3;
1 .data : { *(.data) }
1 }
1 In this example, the symbol 'floating_point' will be defined as zero.
1 The symbol '_etext' will be defined as the address following the last
1 '.text' input section. The symbol '_bdata' will be defined as the
1 address following the '.text' output section aligned upward to a 4 byte
1 boundary.
1