[Gold] Question about the incorrect variable alignment if the alignment is greater than the page size
Alexander Ivchenko
aivchenk@gmail.com
Tue Jun 4 18:52:00 GMT 2013
2013/6/4 Ian Lance Taylor <iant@google.com>:
>> - off = align_file_offset(off, addr, abi_pagesize);
>> + {
>> + // Taking care of the case when the maximum segment alignment
>> + // is larger than the page size.
>> + uint64_t align = ((*p)->maximum_alignment() < abi_pagesize
>> + ? abi_pagesize
>> + : (*p)->maximum_alignment());
>> + off = align_file_offset(off, addr, align);
>> + }
>
> This is C++. It should work to simply do
> off = align_file_offset(off, addr, std::max(abi_pagesize,
> (*p)->maximum_alignment()));
Always forget about that, thanks :) I fixed it.
> In the test, I recommend that rather than using
> large_symbol_alignment.sh you just write your main function to verify
> that the symbols are correctly aligned. And put a space between the
> right parenthesis and "int".
Done. I had to make artificial volatile variables because gcc always tried to
delete the true "if" branch as a dead code (in O0 as well), eventhough
I check in gdb
that the condition is true:
40| if ((reinterpret_cast<uintptr_t>(&aligned_16k_var) & 16383) != 0
41| || (reinterpret_cast<uintptr_t>(&aligned_8k_var) & 8191) != 0
42| || (reinterpret_cast<uintptr_t>(&aligned_4k_var) & 4095) != 0)
43| return 1;
44+> return 0;
(gdb) p (reinterpret_cast<uintptr_t>(&aligned_16k_var) & 16383) != 0
$2 = true
Gcc probably assumes that if the variable been declared with attribute
aligned then it will
certanly have that alignment...
The modifed patch is attached. All make check-gold test passes for me
on x86_64-unknown-linux-gnu.
Is it ok for trunk? If so, could someone commit please? I don't have
commit access.
Thanks,
Alexander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: large_alignment_fix_02.patch
Type: application/octet-stream
Size: 10880 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20130604/3642735e/attachment.obj>
More information about the Binutils
mailing list