The Location Counter - 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

52

4.10.3. The Location Counter

The special linker variable dot
always refers to a location in an output section, it may only appear in an expression within a
command. The
symbol may appear anywhere that an ordinary symbol is allowed in an expression.
.
Assigning a value to
in the output section. The location counter may never be moved backwards.
SECTIONS
{
output :
{
file1(.text)
. = . + 1000;
file2(.text)
. += 1000;
file3(.text)
} = 0x12345678;
}
In the previous example, the
section
. It is followed by a 1000 byte gap. Then the
output
with a 1000 byte gap following before the
specifies what data to write in the gaps (refer to Section 4.6.8.5 Output Section Fill).
Note:
actually refers to the byte offset from the start of the current containing object. Normally this
.
is the
statement, whose start address is 0, hence
SECTIONS
is used inside a section description however, it refers to the byte offset from the start of that section,
not an absolute address. Thus in a script like this:
SECTIONS
{
. = 0x100
.text: {
*(.text)
. = 0x200
}
. = 0x500
.data: {
*(.data)
. += 0x600
}
}
The
section will be assigned a starting address of 0x100 and a size of exactly 0x200 bytes,
.text
even if there is not enough data in the
an error will be produced because this would be an attempt to move
will start at 0x500 and it will have an extra 0x600 bytes worth of space after the end of the values
from the
input sections and before the end of the
.data
always contains the current output location counter. Since the
.
will cause the location counter to be moved. This may be used to create holes
.
section from
.text
.text
is located at the beginning of the output
file1
.text
section from
.text
can be used as an absolute address. If
.
input sections to fill this area. (If there is too much data,
.data
Chapter 4. Linker Scripts
section from
file2
. The notation
file3
backwards). The
.
output section itself.
.
SECTIONS
appears, also
= 0x12345678
.
section
.data

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents