Alignment attribute has no effect under certain conditions
Bug #923397 reported by
Mans Rullgard
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro GCC |
Fix Released
|
Medium
|
Ulrich Weigand | ||
gcc |
Fix Released
|
Medium
|
Bug Description
If an array definition with unspecified size and an alignment attribute is preceded by an extern declaration without the alignment attribute, the alignment attribute is ignored.
Example:
extern const int foo[];
const int __attribute_
Compiling this with Linaro GCC 4.6 (2012.01 release) results in an object file whose .rodata section has a required alignment of only 4 bytes. With Linaro GCC 4.5 and FSF GCC 4.6.2, the correct 16-byte alignment is specified in the output.
Specifying a size in the extern declartion or the definition (or both) also gives the correct result.
Changed in gcc-linaro: | |
status: | Triaged → In Progress |
Changed in gcc-linaro: | |
milestone: | none → 4.6-2012.03 |
Changed in gcc: | |
importance: | Unknown → Medium |
status: | Unknown → Fix Released |
Changed in gcc-linaro: | |
status: | In Progress → Fix Committed |
Changed in gcc-linaro: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Thank you for the bug report. I've confirmed this with gcc-linaro- 4.6-2012. 01 on ARM:
asa-san@ ursa4:~ /bugs/alignment $ ~/bench/ cbuild/ slaves/ ursa4/gcc- linaro- 4.6-2012. 01/gcc- binary/ bin/gcc -c example.c ursa4:~ /bugs/alignment $ readelf -t example.o
asa-san@
There are 11 section headers, starting at offset 0x108:
Section Headers:
[Nr] Name
Type Addr Off Size ES Lk Inf Al
Flags
...
[ 4] .rodata
PROGBITS 00000000 000034 000004 00 0 0 4
[00000002]: ALLOC
...
The work-around, as stated in the ticket, is to specify the size of the array.
The fault also exists in a late revisions of FSF trunk (gcc-4. 7~svn183205) . 4.5-2012. 01. 4.6-2011. 12. Investigation is needed to decide in which revision of gcc-linaro-4.6 the fault was introduced.
The fault does not exist in gcc-linaro-
The fault did not exist in gcc-linaro-
I've set it to medium priority for now, since there is a work around.