Operators; Evaluation - Red Hat ENTERPRISE LINUX 3 - USING ID Using Instructions

Using ld, the gnu linker
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING ID:
Table of Contents

Advertisement

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
.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents