54
4.10.6. The Section of an Expression
When the linker evaluates an expression, the result is either absolute or relative to some section. A
relative expression is expressed as a fixed offset from the base of a section.
The position of the expression within the linker script determines whether it is absolute or relative.
An expression which appears within an output section definition is relative to the base of the output
section. An expression which appears elsewhere will be absolute.
A symbol set to a relative expression will be relocatable if you request relocatable output using the
option. That means that a further link operation may change the value of the symbol. The symbol's
section will be the section of the relative expression.
A symbol set to an absolute expression will retain the same value through any further link operation.
The symbol will be absolute, and will not have any particular associated section.
You can use the builtin function
otherwise be relative. For example, to create an absolute symbol set to the address of the end of the
output section
.data
SECTIONS
{
.data : { *(.data) _edata = ABSOLUTE(.); }
}
If
were not used,
ABSOLUTE
4.10.7. Builtin Functions
The linker script language includes a number of builtin functions for use in linker script expressions.
ABSOLUTE(
)
exp
Return the absolute (non-relocatable, as opposed to non-negative) value of the expression
Primarily useful to assign an absolute value to a symbol within a section definition, where symbol
values are normally section relative. Refer to Section 4.10.6 The Section of an Expression.
ADDR(
)
section
Return the absolute address (the VMA) of the named
have defined the location of that section. In the following example,
are assigned identical values:
SECTIONS { ...
.output1 :
{
start_of_output_1 = ABSOLUTE(.);
...
}
.output :
{
symbol_1 = ADDR(.output1);
symbol_2 = start_of_output_1;
}
... }
ABSOLUTE
:
would be relative to the
_edata
to force an expression to be absolute when it would
.data
section
Chapter 4. Linker Scripts
section.
. Your script must previously
and
symbol_1
-r
.
exp
symbol_2
Need help?
Do you have a question about the ENTERPRISE LINUX 3 - USING ID and is the answer not in the manual?
Questions and answers