TLS orphan section placement
H.J. Lu
hjl.tools@gmail.com
Fri Jan 24 18:04:00 GMT 2014
On Fri, Jan 24, 2014 at 9:07 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> 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.
>
I checked in this patch to replace .align with .p2align.
--
H.J.
--
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 9e8553a..39cc0fb 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2014-01-24 H.J. Lu <hongjiu.lu@intel.com>
+ * ld-elf/pr16498a.s: Replace .align with .p2align.
+
+2014-01-24 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/16498
* ld-elf/pr16498b.d: New file.
* ld-elf/pr16498b.t: Likewise.
diff --git a/ld/testsuite/ld-elf/pr16498a.s b/ld/testsuite/ld-elf/pr16498a.s
index 77f80e6..be503a2 100644
--- a/ld/testsuite/ld-elf/pr16498a.s
+++ b/ld/testsuite/ld-elf/pr16498a.s
@@ -1,6 +1,6 @@
.globl data
.data
- .align 32
+ .p2align 5
.type data, %object
.size data, 120
data:
@@ -8,14 +8,14 @@ data:
.zero 116
.globl foo
.section .tbss,"awT",%nobits
- .align 4
+ .p2align 2
.type foo, %object
.size foo, 4
foo:
.zero 4
.globl bar
.section .tdata,"awT",%progbits
- .align 16
+ .p2align 4
.type bar, %object
.size bar, 80
bar:
More information about the Binutils
mailing list