[gold] Merging string literals with bigger alignment
Cary Coutant
ccoutant@google.com
Thu Apr 4 17:13:00 GMT 2013
> Hi, I implemented (b2) as we discussed above. Could you please take a look.
+ // We assume here that the beginning of the section is correctly
+ // aligned, so each string within the section must retain the same
+ // modulo.
+ uint64_t init_align_modulo = (uint64_t) pdata % this->addralign();
The type should be uintptr_t, and the cast should be
reinterpret_cast<uintptr_t>(pdata):
uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata)
& (this->addralign() - 1));
+ // Within merge input section each string must be aligned.
+ if ((uint64_t) p % this->addralign() != init_align_modulo)
+ has_misaligned_strings = true;
With a variable operand, the % operator is quite a bit slower than
masking. Please rewrite this as
if ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1))
!= init_align_modulo)
has_misaligned_strings = true;
Aside from those changes, this looks good to me. Thanks!
(You still need Ian's approval to commit.)
-cary
More information about the Binutils
mailing list