From d85e71fec0aa4d9d8ca0d8c2401cd8ab69fe2edc Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 22 Jan 2014 11:24:12 -0800 Subject: [PATCH] Improve orphaned TLS section handling ld/ PR ld/16498 * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Improve orphaned TLS section handling. ld/testsuite/ PR ld/16498 * ld-elf/pr16498a.d: New file. * ld-elf/pr16498a.s: Likewise. * ld-elf/pr16498a.t: Likewise. --- ld/ChangeLog | 6 ++++++ ld/emultempl/elf32.em | 6 ++++++ ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-elf/pr16498a.d | 9 +++++++++ ld/testsuite/ld-elf/pr16498a.s | 23 +++++++++++++++++++++++ ld/testsuite/ld-elf/pr16498a.t | 6 ++++++ 6 files changed, 57 insertions(+) create mode 100644 ld/testsuite/ld-elf/pr16498a.d create mode 100644 ld/testsuite/ld-elf/pr16498a.s create mode 100644 ld/testsuite/ld-elf/pr16498a.t diff --git a/ld/ChangeLog b/ld/ChangeLog index 9beee8c6065..dcf0b159e06 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2014-01-24 H.J. Lu + + PR ld/16498 + * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Improve + orphaned TLS section handling. + 2014-01-24 Alan Modra * ldlang.c (lang_output_section_find_by_flags): Be careful to diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index a4f04f15c1b..fda0e687442 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1812,6 +1812,9 @@ gld${EMULATION_NAME}_place_orphan (asection *s, { ".rodata", SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA, 0, 0, 0, 0 }, + { ".tdata", + SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_THREAD_LOCAL, + 0, 0, 0, 0 }, { ".data", SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_DATA, 0, 0, 0, 0 }, @@ -1835,6 +1838,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, { orphan_text = 0, orphan_rodata, + orphan_tdata, orphan_data, orphan_bss, orphan_rel, @@ -1962,6 +1966,8 @@ gld${EMULATION_NAME}_place_orphan (asection *s, place = &hold[orphan_bss]; else if ((s->flags & SEC_SMALL_DATA) != 0) place = &hold[orphan_sdata]; + else if ((s->flags & SEC_THREAD_LOCAL) != 0) + place = &hold[orphan_tdata]; else if ((s->flags & SEC_READONLY) == 0) place = &hold[orphan_data]; else if (((iself && (sh_type == SHT_RELA || sh_type == SHT_REL)) diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a269b079ea4..4f0a75bbe85 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-01-24 H.J. Lu + + PR ld/16498 + * ld-elf/pr16498a.d: New file. + * ld-elf/pr16498a.s: Likewise. + * ld-elf/pr16498a.t: Likewise. + 2014-01-22 Alan Modra * ld-scripts/pr14962-2.d: Correct target triple. diff --git a/ld/testsuite/ld-elf/pr16498a.d b/ld/testsuite/ld-elf/pr16498a.d new file mode 100644 index 00000000000..436bf971ab7 --- /dev/null +++ b/ld/testsuite/ld-elf/pr16498a.d @@ -0,0 +1,9 @@ +#ld: -shared -T pr16498a.t +#readelf: -l --wide +#target: *-*-linux* *-*-gnu* *-*-nacl* + +#... + TLS .* +#... +[ ]+[0-9]+[ ]+.tdata .tbss[ ]* +#pass diff --git a/ld/testsuite/ld-elf/pr16498a.s b/ld/testsuite/ld-elf/pr16498a.s new file mode 100644 index 00000000000..77f80e6848f --- /dev/null +++ b/ld/testsuite/ld-elf/pr16498a.s @@ -0,0 +1,23 @@ + .globl data + .data + .align 32 + .type data, %object + .size data, 120 +data: + .long 1 + .zero 116 + .globl foo + .section .tbss,"awT",%nobits + .align 4 + .type foo, %object + .size foo, 4 +foo: + .zero 4 + .globl bar + .section .tdata,"awT",%progbits + .align 16 + .type bar, %object + .size bar, 80 +bar: + .long 1 + .zero 76 diff --git a/ld/testsuite/ld-elf/pr16498a.t b/ld/testsuite/ld-elf/pr16498a.t new file mode 100644 index 00000000000..928724faba8 --- /dev/null +++ b/ld/testsuite/ld-elf/pr16498a.t @@ -0,0 +1,6 @@ +SECTIONS +{ + .tdata : { *(.tdata) } + .data : { *(.data) + } +} -- 2.30.2