linker script: location counter & memory interference

Ángel González
Thu Aug 29 12:12:00 GMT 2013

On 29/08/13 13:42, Michael Weise wrote:
> This might point to the problem:
> --citation--
> .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.
> --/citation--
> from
> What is "strictest alignment"?
A bit of background:
On some architectures, there are restrictions on the memory alignment of
data depending on its type.
For instance you may be able to access a char wherever it's placed, but
a uint32_t must be on a 4-byte aligned address and a uint64_t on a 8-byte
aligned address.
The compiler ensures that the variables are aligned accordingly by padding
or reordering them to fit those constraints.
Instructions may have similar alignment restrictions.

AFAIK the is "strictest alignment" would be in the above example an 8-byte
alignment (you are also 4-byte aligned by being 8-byte aligned).

More information about the Gcc-help mailing list