Chapter 4. Linker Scripts
4.10.4. Operators
The linker recognizes the standard C set of arithmetic operators, with the standard bindings and prece-
dence levels:
precedence
(highest)
1
2
3
4
5
6
7
8
9
10
11
(lowest)
Notes: (1) Prefix operators (2) Refer to Section 4.5 Assigning Values to Symbols.
4.10.5. Evaluation
The linker evaluates expressions lazily. It only computes the value of an expression when absolutely
necessary.
The linker needs some information, such as the value of the start address of the first section, and the
origins and lengths of memory regions, in order to do any linking at all. These values are computed
as soon as possible when the linker reads in the linker script.
However, other values (such as symbol values) are not known or needed until after storage alloca-
tion. Such values are evaluated later, when other information (such as the sizes of output sections) is
available for use in the symbol assignment expression.
The sizes of sections cannot be known until after allocation, so assignments dependent upon these are
not performed until after allocation.
Some expressions, such as those depending upon the location counter
section allocation.
If the result of an expression is required, but the value is not available, then an error results. For
example, a script like the following
SECTIONS
{
.text 9+this_isnt_constant :
{ *(.text) }
}
will cause the error message
associativity
left
left
left
left
left
left
left
left
left
right
right
non constant expression for initial address
Operators
!
-
~
*
/
%
+
-
==
!=
&
|
&&
||
? :
&=
+=
-=
*=
Notes
(1)
=
=
/=
(2)
, must be evaluated during
.
53
.
Need help?
Do you have a question about the ENTERPRISE LINUX 4 - USING ID and is the answer not in the manual?
Questions and answers