diff options
author | Nick Clifton <nickc@redhat.com> | 2007-11-20 15:08:25 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2007-11-20 15:08:25 +0000 |
commit | 430a16a51d442dd9c7f91631388815d54c70481f (patch) | |
tree | 55b2da5727325f2f8c2600aac85cd4d119e4db05 | |
parent | 2207132da48e8347055233edd8cc6b8abffdd0a0 (diff) | |
download | gdb-430a16a51d442dd9c7f91631388815d54c70481f.zip gdb-430a16a51d442dd9c7f91631388815d54c70481f.tar.gz gdb-430a16a51d442dd9c7f91631388815d54c70481f.tar.bz2 |
* elflink.c (elf_link_output_extsym): Weaken assertion: if --gc-section is set, there may be no TLS segment.
* lib/ld-lib.exp (check_gc_sections_available): New proc, based on the version in gcc/testsuite/lib/target-supports.exp.
* ld-elf/eld.exp: Use check_gc_sections_available.
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elflink.c | 13 | ||||
-rw-r--r-- | ld/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/elf.exp | 7 | ||||
-rw-r--r-- | ld/testsuite/lib/ld-lib.exp | 42 |
5 files changed, 74 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f85cf92..c02027b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2007-11-16 Tristan Gingold <gingold@adacore.com> + + * elflink.c (elf_link_output_extsym): Weaken assertion: if + --gc-section is set, there may be no TLS segment. + 2007-11-19 Alan Modra <amodra@bigpond.net.au> * elf-bfd.h (bfd_elf_perform_complex_relocation): Update prototype. diff --git a/bfd/elflink.c b/bfd/elflink.c index 63a8c65..48072f8 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -8536,10 +8536,15 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data) sym.st_value += input_sec->output_section->vma; if (h->type == STT_TLS) { - /* STT_TLS symbols are relative to PT_TLS segment - base. */ - BFD_ASSERT (elf_hash_table (finfo->info)->tls_sec != NULL); - sym.st_value -= elf_hash_table (finfo->info)->tls_sec->vma; + asection *tls_sec = elf_hash_table (finfo->info)->tls_sec; + if (tls_sec != NULL) + sym.st_value -= tls_sec->vma; + else + { + /* The TLS section may have been garbage collected. */ + BFD_ASSERT (finfo->info->gc_sections + && !input_sec->gc_mark); + } } } } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5d601f2..da6d9b0 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2007-11-20 Nick Clifton <nickc@redhat.com> + + * lib/ld-lib.exp (check_gc_sections_available): New proc, based + on the version in gcc/testsuite/lib/target-supports.exp. + * ld-elf/elf.exp: Use check_gc_sections_available. + +2007-11-20 Tristan Gingold <gingold@adacore.com> + + * ld-elf/tls_gc.s: New test. + * ld-elf/elf.exp: Add tls_gc test. + 2007-11-17 Thiemo Seufer <ths@mips.com> * ld-mips-elf/attr-gnu-4-14.d, ld-mips-elf/attr-gnu-4-41.d: diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index dc6a3a6..080d985 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -53,6 +53,13 @@ if { [istarget *-*-linux*] } { } } +if { [check_gc_sections_available] } { + run_ld_link_tests { + {"--gc-sections on tls variable" + "--gc-section" "" {tls_gc.s} {} "tls_gc"} + } +} + # The following tests require running the executable generated by ld. if ![isnative] { return diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 456e9fd..f326478 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -1535,3 +1535,45 @@ proc run_cc_link_tests { ldtests } { } } } + +# Returns true if --gc-sections is supported on the target. + +proc check_gc_sections_available { } { + global gc_sections_available_saved + global ld + + if {![info exists gc_sections_available_saved]} { + # Some targets don't support gc-sections despite whatever's + # advertised by ld's options. + if { [istarget alpha*-*-*] + || [istarget ia64-*-*] } { + set gc_sections_available_saved 0 + return 0 + } + + # elf2flt uses -q (--emit-relocs), which is incompatible with + # --gc-sections. + if { [board_info target exists ldflags] + && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } { + set gc_sections_available_saved 0 + return 0 + } + + # VxWorks kernel modules are relocatable objects linked with -r, + # while RTP executables are linked with -q (--emit-relocs). + # Both of these options are incompatible with --gc-sections. + if { [istarget *-*-vxworks*] } { + set gc_sections_available_saved 0 + return 0 + } + + # Check if the ld used by gcc supports --gc-sections. + set ld_output [remote_exec host $ld "--help"] + if { [ string first "--gc-sections" $ld_output ] >= 0 } { + set gc_sections_available_saved 1 + } else { + set gc_sections_available_saved 0 + } + } + return $gc_sections_available_saved +} |