TLS orphan section placement
H.J. Lu
hjl.tools@gmail.com
Fri Jan 24 17:07:00 GMT 2014
On Fri, Jan 24, 2014 at 4:53 AM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Jan 22, 2014 at 08:19:31PM -0800, H.J. Lu wrote:
>> On Wed, Jan 22, 2014 at 7:55 PM, Alan Modra <amodra@gmail.com> wrote:
>> > On Wed, Jan 22, 2014 at 11:30:13AM -0800, H.J. Lu wrote:
>> >> PR ld/16498
>> >> * elf.c (_bfd_elf_map_sections_to_segments): Issue a linker error
>> >> if TLS sections are not adjacent.
>> >
>> > This part is OK.
>>
>> I'd like to augment my patch like
>
> Yes, this is OK too.
>
>> > On the other hand, the testcase is really showing a fault in orphan
>> > section handling. If ld was a little more clever, it would put .tbss
>> > after .tdata and your testcase would no longer give an error.
>> >
>>
>> I am enclosing a simple patch which does it. However, it
>> doesn't solve the second testcase in the bug report since
>> it has a linker script:
>>
>> ---
>> SECTIONS
>> {
>> tls_data_init : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
>> .data :
>> {
>> *(.data .data.* .gnu.linkonce.d.*)
>> }
>> /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
>> }
>> ---
>
> Besides the place_orphan change you posted, which is OK to commit,
> you need something like the following.
>
> Ensures TLS orphans are placed adjacent to existing TLS sections,
> and fixes places where the output_section_statement flags (which might
> not be set) were tested when bfd_section flags were available.
>
> * ldlang.c (lang_output_section_find_by_flags): Be careful to
> test look->bfd_section->flags if available rather than
> look->flags. Separate SEC_THREAD_LOCAL handling from
> SEC_READONLY loop, and rewrite.
>
These are 2 patches I checked in.
Thanks.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Improve-orphaned-TLS-section-handling.patch
Type: text/x-patch
Size: 4013 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20140124/853530b4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-another-testcase-for-PR-ld-16498.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20140124/853530b4/attachment-0001.bin>
More information about the Binutils
mailing list