This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: linker script: location counter & memory interference
- From: Ángel González <keisial at gmail dot com>
- To: Michael Weise <michael dot weise at ek-team dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 29 Aug 2013 14:16:50 +0200
- Subject: Re: linker script: location counter & memory interference
- Authentication-results: sourceware.org; auth=none
- References: <20130829134203 dot 48545fb26df7743443dc2be4 at ek-team dot de>
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
http://www.scoberlin.de/content/media/http/informatik/gcc_docs/ld_3.html
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).