Contents|Index|Previous|Next

The Location Counter

The special linker variable dot ‘.’ always contains the current output location counter. Since the ‘.’ always refers to a location in an output section, it must always appear in an expression within a SECTIONS command. The ‘.’ symbol may appear anywhere that an ordinary symbol is allowed in an expression, but its assignments have a side effect. Assigning a value to the ‘.’ symbol will cause the location counter to be moved. This may be used to create holes in the output section. The location counter may never be moved backwards.

SECTIONS
{
output :
{
file1(.text)
. = . + 1000;
file2(.text)
. += 1000;
file3(.text)
} = 0x1234;
}

In the previous example, file1 is located at the beginning of the output section, then there is a 1000 byte gap. Then file2 appears, also followed by a 1000 byte gap before file3 is loaded. ‘= 0x1234’ specifies what data to write in the gaps (see Optional Section Attributes ).