10.5.5.6 Output Section Address
The address is an expression for the VMA (the virtual memory address) of
the output section. If address
is not provided, the
linker will set it based on region if present, or otherwise based on the current value of
the location counter.
If address
is provided, the address of
the output section will be set to precisely that. If neither address
nor region
is provided, then the address of the output section will be
set to the current value of the location counter aligned to the alignment requirements of
the output section. The alignment requirement of the output section is the strictest
alignment of any input section contained within the output section.
For example,
.text . : { *(.text) }
and
.text : { *(.text) }
are subtly different. The first will set the address of the .text
output section to the current value of the location counter. The second will set it to the current value of the location counter aligned to the strictest alignment of a .text
input section.
The address may be an arbitrary expression (Expressions in Linker Scripts ). For example, to
align the section on a 0x10
byte boundary, so that the
lowest four bits of the section address are zero, the command could look like this:
.text ALIGN(0x10) : { *(.text) }
This works because ALIGN
returns the current location counter aligned upward to the specified value.
Specifying address
for a section will change the value of the location counter.