[Gold] Question about the incorrect variable alignment if the alignment is greater than the page size
Alexander Ivchenko
aivchenk@gmail.com
Fri May 31 11:13:00 GMT 2013
Hi,
I'm trying to compile and link (with Gold) the code for elf_i386,
which looks something like that:
__attribute__((aligned(8192))) int 8k_aligned_var;
int main()
{
if( ( (((int)&8k_aligned_var) & 8191) == 0) {
printf("passed\n");
}
else {
printf("failed\n");
return 1;
}
return 0;
}
And gold does not align "8k_aligned_var" correctly:
++ readelf -a test_gold.exe
++ grep 8k_aligned_var
31: 0804d000 4 OBJECT GLOBAL DEFAULT 19 8k_aligned_var
However, if we increase the page size using "-z max-page-size=0x4000"
then the test works:
++ readelf -a test_gold.exe
++ grep 8k_aligned_var
31: 08052000 4 OBJECT GLOBAL DEFAULT 19 8k_aligned_var
Also please note that the test works for bfd:
++ readelf -a test_bfd.exe
++ grep 8k_aligned_var
34: 0804c000 4 OBJECT GLOBAL DEFAULT 17 8k_aligned_var
Was that behavior made intentionally or it's just a bug?
I know that it's a pretty big alignment and that could be suspicious,
but we can at least warn the user that his code won't be linked the
way it was written.
thanks,
Alexander
More information about the Binutils
mailing list