Simple Assignments; Provide - 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

34

4.5.1. Simple Assignments

You may assign to a symbol using any of the C assignment operators:
• symbol
=
expression
• symbol
+=
expression
• symbol
-=
expression
• symbol
*=
expression
• symbol
/=
expression
• symbol
=
expression
¥ ¦ ¥
• symbol
=
expression
§ ¦ §
• symbol
&=
expression
• symbol
|=
expression
The first case will define
already be defined, and the value will be adjusted accordingly.
The special symbol name
command.
The semicolon after
Expressions are defined below; refer to Section 4.10 Expressions in Linker Scripts.
You may write symbol assignments as commands in their own right, or as statements within a
command, or as part of an output section description in a
SECTIONS
The section of the symbol will be set from the section of the expression; for more information, refer
to Section 4.10.6 The Section of an Expression.
Here is an example showing the three different places that symbol assignments may be used:
floating_point = 0;
SECTIONS
{
.text :
{
*(.text)
_etext = .;
}
_bdata = (. + 3) & ~ 3;
.data : { *(.data) }
}
In this example, the symbol
defined as the address following the last
the address following the

4.5.2. PROVIDE

In some cases, it is desirable for a linker script to define a symbol only if it is referenced and is
not defined by any object included in the link. For example, traditional linkers defined the symbol
. However, ANSI C requires that the user be able to use
etext
encountering an error. The
if it is referenced but not defined. The syntax is
Here is an example of using
;
;
;
;
;
;
;
;
;
to the value of
symbol
indicates the location counter. You may only use this within a
.
is required.
expression
floating_point
.text
output section aligned upward to a 4 byte boundary.
.text
keyword may be used to define a symbol, such as
PROVIDE
to define
PROVIDE
. In the other cases,
expression
will be defined as zero. The symbol
input section. The symbol
etext
PROVIDE(
=
symbol
:
etext
Chapter 4. Linker Scripts
symbol
command.
SECTIONS
_etext
will be defined as
_bdata
as a function name without
etext
.
)
expression
must
SECTIONS
will be
, only

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents