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>, Sriraman Tallam <tmsriram at google dot com>
- Date: Fri, 22 Mar 2013 09:34:39 -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>
> But isn't that defined that if the string is placed in, say,
> rodata.1.8 section, than
> we can count that its alignment is 8? If the user doesn't want that string to
> be 8-aligned or wants 4 modulo 8 then he\she should not put that string in
> 8-aligned section. As far as I understand BFD merge code is not checking that
> (why should it?) and we are compatible
In a non-merge section, the internal alignments are preserved simply
by preserving the beginning alignment. In a merge section, that's not
going to happen automatically, so it should either be detected as an
error or handled in a natural way. I'm not saying we should support it
-- if you've got a .rodata.1.8 SHF_MERGE section, it's reasonable to
assume that all strings within the section would be aligned. But what
if the compiler does something strange, or makes a contrary
assumption? If we accept the convention that all strings in the
section should be aligned, I think it would be a good idea to insert a
simple check into the code and print an error message. I think the BFD
linker should do that, too.
Also, when processing the section in
Output_merge_string::do_add_input_section, we count the strings in the
section essentially by counting the null characters. This will count
each padding byte as a separate string, so we'll get an inflated
estimate of the number of strings. If we accept the above convention,
the compiler should never point to any of these (unaligned) padding
bytes as a null string, so we shouldn't need to count them or call
add_with_length_and_alignment for all those null strings. In other
words, once we add a string, we should skip ahead to the next
alignment boundary.
-cary