ld: Evaluation

1 
1 3.10.7 Evaluation
1 -----------------
1 
1 The linker evaluates expressions lazily.  It only computes the value of
1 an expression when absolutely necessary.
1 
1    The linker needs some information, such as the value of the start
1 address of the first section, and the origins and lengths of memory
1 regions, in order to do any linking at all.  These values are computed
1 as soon as possible when the linker reads in the linker script.
1 
1    However, other values (such as symbol values) are not known or needed
1 until after storage allocation.  Such values are evaluated later, when
1 other information (such as the sizes of output sections) is available
1 for use in the symbol assignment expression.
1 
1    The sizes of sections cannot be known until after allocation, so
1 assignments dependent upon these are not performed until after
1 allocation.
1 
1    Some expressions, such as those depending upon the location counter
1 '.', must be evaluated during section allocation.
1 
1    If the result of an expression is required, but the value is not
1 available, then an error results.  For example, a script like the
1 following
1      SECTIONS
1        {
1          .text 9+this_isnt_constant :
1            { *(.text) }
1        }
1 will cause the error message 'non constant expression for initial
1 address'.
1