http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56334
Bug #: 56334
Summary: __attribute__((aligned)) documentation is outdated and
misleading.
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: [email protected]
ReportedBy: [email protected]
The documentation of the "aligned" attribute
(http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html) states:
"Note that the effectiveness of aligned attributes may be limited by inherent
limitations in your linker. On many systems, the linker is only able to arrange
for variables to be aligned up to a certain maximum alignment. (For some
linkers, the maximum supported alignment may be very very small.) If your
linker is only able to align variables up to a maximum of 8-byte alignment,
then specifying aligned(16) in an __attribute__ still only provides you with
8-byte alignment. See your linker documentation for further information."
This is erroneous in two ways:
(1) As of the closure of bug 33721, we generate code to align variables at
runtime when the linker cannot guarantee a given alignment at link time. Thus,
the effectiveness is no longer limited by the linker -- but it is probably
useful to mention that there can be some (very minor) runtime cost.
(2) The statement "See your linker documentation for further information" is
entirely unhelpful, because the GNU ld documentation makes no mention of
alignment limitations (or, for that matter, of aligning variables at all).
This point is probably moot if we fix item 1, but if it remains, it would be
helpful to note that the real issue is that GCC aligns things with respect to
the start of the relevant block of instructions and then the linker is
responsible for aligning that block.