[PATCH] Sparc32 ELF TLS fixes
Alan Modra
amodra@bigpond.net.au
Mon Apr 11 23:04:00 GMT 2005
On Mon, Apr 11, 2005 at 12:11:33PM -0700, David S. Miller wrote:
> The .rodata starts as .rodata.str1.8 in sr3.o:
>
> Contents of section .rodata.str1.8:
> 0000 6175746f 6d617469 635f666f 6f000000 automatic_foo...
> 0010 73746174 69635f66 6f6f0000 00000000 static_foo......
>
> It is in fact 32 bytes. But something causes it to shrink when
> outputting ELF. And this something is _bfd_elf_merge_sections().
> The above is the only .rodata.* section, so it is the only one
> processed during _bfd_merge_sections(). It trims the strings so
> that there are no spurious NULL bytes. And that's how we end up
> with a 27 byte .rodata output section from the original 32 byte
> input section.
That sounds like a ld bug. The strings shouldn't have their
alignment changed. Since gcc is emitting them to a .rodata.str1.8
section, I'd expect readelf -S sr3.o should show something like
.. .rodata.str1.8 PROGBITS .. .. .. 01 AMS 0 0 8
The section alignment tells the merge code to not reduce string
alignment below that value.
> I don't see any reasonable way to fix this besides possibly disabling
> section merging via command line option for this test case. Is there
> even a way to turn SEC_MERGE processing off from the ld command line?
No, this optimization is controlled by the section flags. Turn it off
with gcc's --fno-merge-constants.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list