32
Chapter 5. Sections and Relocation
Further, most expressions
as
computes have this section relative nature. (For some object formats,
such as SOM for the HPPA, some expressions are symbol relative instead.)
In this manual we use the notation {
secname N
} to mean "offset
N
into section
secname
."
Apart from text, data and bss sections you need to know about the absolute section. When
ld
mixes partial programs, addresses in the absolute section remain unchanged. For example, address
{absolute 0}
is "relocated" to run time address 0 by
ld
. Although the linker never arranges two
partial programs' data sections with overlapping addresses after linking, by definition their absolute
sections must overlap. Address
{absolute 239}
in one part of a program is always the same
address when the program is running as address
{absolute 239}
in any other part of the program.
The idea of sections is extended to the undefined section. Any address whose section is unknown at
assembly time is by definition rendered {undefined
U
} where
U
is filled in later. Since numbers are
always defined, the only way to generate an undefined address is to mention an undefined symbol. A
reference to a named common block would be such a symbol: its value is unknown at assembly time
so it has section undefined.
By analogy the word section is used to describe groups of sections in the linked program.
ld
puts
all partial programs' text sections in contiguous addresses in the linked program. It is customary to
refer to the text section of a program, meaning all the addresses of all partial programs' text sections.
Likewise for data and bss sections.
Some sections are manipulated by
ld
; others are invented for use of
as
and have no meaning except
during assembly.
5.2. Linker Sections
ld
deals with just four kinds of sections, summarized below.
named sections
text section
data section
These sections hold your program.
as
and
ld
treat them as separate but equal sections. Anything
you can say of one section is true of another. When the program is running, however, it is cus
tomary for the text section to be unalterable. The text section is often shared among processes:
it contains instructions, constants and the like. The data section of a running program is usually
alterable: for example, C variables would be stored in the data section.
bss section
This section contains zeroed bytes when your program begins running. It is used to hold uninitial
ized variables or common storage. The length of each partial program's bss section is important,
but because it starts out containing zeroed bytes there is no need to store explicit zero bytes in
the object file. The bss section was invented to eliminate those explicit zeros from object files.
absolute section
Address 0 of this section is always "relocated" to runtime address 0. This is useful if you want to
refer to an address that
ld
must not change when relocating. In this sense we speak of absolute
addresses being "unrelocatable": they do not change during relocation.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved