This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [gold] Merging string literals with bigger alignment
- From: Cary Coutant <ccoutant at google dot com>
- To: Alexander Ivchenko <aivchenk at gmail dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, binutils <binutils at sourceware dot org>
- Date: Thu, 4 Apr 2013 10:13:54 -0700
- Subject: Re: [gold] Merging string literals with bigger alignment
- References: <CACysShhXDPxUsqdUprwhyGcaNiS9X_ODbrW847wHHiwbUh4LhA at mail dot gmail dot com> <CAKOQZ8xROxuJMD19P7JoM084LDyDKk_anwiuoWRpS+2MLeThnA at mail dot gmail dot com> <CACysShhaCv68A39oTk5FfmsdRFjhoOjQEzEZys4U0-sZs-x+4A at mail dot gmail dot com> <CAKOQZ8ypF=yCMmrwn-8jSp_WBMdrNi6NqwJRqabG7ZUwV2yMhg at mail dot gmail dot com> <CACysShhyE2G_8fz1pLSjTdJ_f9OYdSHHB9zvydWPaJNHjFkQ8g at mail dot gmail dot com> <CAKOQZ8wd_7bfSfMsm_WmJnSdT_J4qF-JM+3Ex=tU0iDJCOWETQ at mail dot gmail dot com> <CACysShh22grCuoa7-b3QV7D_Q-RBYrtLH8ifr2yRcS93+GRk1g at mail dot gmail dot com> <CAHACq4pqmPp7JqwOJ_Ux0NN7yVZzq82t4uf9ZUKTa8eXL+Znrg at mail dot gmail dot com> <CACysShjRoZMEp=JasvdY9Jg=+ab15FEEUY-WnR-4dLb9q+C-Cg at mail dot gmail dot com> <CAHACq4rEinAxU_5Cp7SQiNeZN8tZsbp-YCwbuzR-bC5Z9GOrJw at mail dot gmail dot com> <CACysShh_8waYTA4tQWGnRER5xrwv=NgSn2NRhzOLfncPuOeOsg at mail dot gmail dot com> <CAHACq4odyq1ok_SWBFNUDreq8=b-4MMqp3DXJY03viF2-HUe8w at mail dot gmail dot com> <CACysShj2TB84vkATNQhDVYx7QURtx29Qpb5t+i_i2OP6R-zgZQ at mail dot gmail dot com> <CAHACq4q4=bd1gB9LEBJRwOnqDTYQxZ_Z=BKN++M0KSPqDdGJtg at mail dot gmail dot com> <CACysShjX+kaq8CAcCWDMcvChGrUPYNz4XQGYbk+okV2baGPfJQ at mail dot gmail dot com> <CAHACq4rN=nj5wX5AJYwKSbqnDfbMPC=p9CvGJR-y-JjKi=0gqw at mail dot gmail dot com> <CAKOQZ8y7DMUSWh5dozvxBD1a8uW981K+Gwn95JTqcGFkAHdVOg at mail dot gmail dot com> <CACysShhF+sh1vebktXwoc6epBJ8FQTMTjXRURm7nJT9MfjUvLA at mail dot gmail dot com>
> 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