aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2009-08-07 18:29:54 +0000
committerSriraman Tallam <tmsriram@google.com>2009-08-07 18:29:54 +0000
commit277210621532e70db4d9cdebce345d1c7846dacf (patch)
treef28a1f0b4e589de2341354f61ccf87eeabfa8e7b /gold
parent918d9742419429e4f063e4f8ff624f00237456a4 (diff)
downloadgdb-277210621532e70db4d9cdebce345d1c7846dacf.zip
gdb-277210621532e70db4d9cdebce345d1c7846dacf.tar.gz
gdb-277210621532e70db4d9cdebce345d1c7846dacf.tar.bz2
*** empty log message ***
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog9
-rw-r--r--gold/testsuite/Makefile.am9
-rw-r--r--gold/testsuite/Makefile.in21
-rw-r--r--gold/testsuite/gc_tls_test.cc32
-rwxr-xr-xgold/testsuite/gc_tls_test.sh39
-rw-r--r--gold/x86_64.cc12
6 files changed, 111 insertions, 11 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 09ea43e..72241b6 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,12 @@
+2009-08-06 Sriraman Tallam <tmsriram@google.com>
+
+ * x86_64.cc (Target_x86_64::Relocate::relocate_tls): Check for a
+ valid tls_segment only for non-debug-section relocations.
+ * testsuite/Makefile.am: Add gc_tls_test.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/gc_tls_test.cc: New file.
+ * testsuite/gc_tls_test.sh: New file.
+
2009-08-05 Sriraman Tallam <tmsriram@google.com>
* icf.cc: New file.
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index ca177bd..6693f00 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -115,6 +115,15 @@ gc_comdat_test: gc_comdat_test_1.o gc_comdat_test_2.o gcctestdir/ld
gc_comdat_test.stdout: gc_comdat_test
$(TEST_NM) -C gc_comdat_test > gc_comdat_test.stdout
+check_SCRIPTS += gc_tls_test.sh
+check_DATA += gc_tls_test.stdout
+gc_tls_test.o: gc_tls_test.cc
+ $(CXXCOMPILE) -O0 -c -g -o $@ $<
+gc_tls_test:gc_tls_test.o gcctestdir/ld
+ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_tls_test.o
+gc_tls_test.stdout: gc_tls_test
+ $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout
+
check_SCRIPTS += icf_test.sh
check_DATA += icf_test.stdout
icf_test.o: icf_test.cc
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index d6b43bd..7458f3f 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -57,12 +57,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
# Test --dynamic-list, --dynamic-list-data, --dynamic-list-cpp-new,
# and --dynamic-list-cpp-typeinfo
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = gc_comdat_test.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh two_file_shared.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_plt.sh debug_msg.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.sh ver_test_1.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2.sh ver_test_4.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_5.sh ver_test_7.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_10.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.sh icf_test.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.sh weak_plt.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg.sh undef_symbol.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_1.sh ver_test_2.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_4.sh ver_test_5.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_7.sh ver_test_10.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_matching_test.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3.sh \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_4.sh \
@@ -75,6 +75,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
# We also want to make sure we do something reasonable when there's no
# debug info available. For the best test, we use .so's.
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = gc_comdat_test.stdout \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.stdout \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.dbg \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_plt_shared.so debug_msg.err \
@@ -347,7 +348,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
subdir = testsuite
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/../config/gettext-sister.m4 \
@@ -2318,6 +2319,12 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_comdat_test_1.o gc_comdat_test_2.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_comdat_test.stdout: gc_comdat_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C gc_comdat_test > gc_comdat_test.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_tls_test.o: gc_tls_test.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -g -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_tls_test:gc_tls_test.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_tls_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_tls_test.stdout: gc_tls_test
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout
@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld
diff --git a/gold/testsuite/gc_tls_test.cc b/gold/testsuite/gc_tls_test.cc
new file mode 100644
index 0000000..1b10d98
--- /dev/null
+++ b/gold/testsuite/gc_tls_test.cc
@@ -0,0 +1,32 @@
+// gc_tls_test.cc -- a test case for gold
+
+// Copyright 2009 Free Software Foundation, Inc.
+// Written by Sriraman Tallam <tmsriram@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// The goal of this program is to verify if tls sections are garbage
+// collected with --gc-sections.
+
+__thread int number;
+
+int main()
+{
+ return 0;
+}
+
diff --git a/gold/testsuite/gc_tls_test.sh b/gold/testsuite/gc_tls_test.sh
new file mode 100755
index 0000000..c4635c9
--- /dev/null
+++ b/gold/testsuite/gc_tls_test.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# gc_tls_test.sh -- test -- gc + tls
+
+# Copyright 2009 Free Software Foundation, Inc.
+# Written by Sriraman Tallam <tmsriram@google.com>.
+
+# This file is part of gold.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The goal of this program is to verify if tls sections are garbage
+# collected with --gc-sections. File gc_tls_test.cc is in this test.
+
+check()
+{
+ if grep -q "$2" "$1"
+ then
+ echo "Garbage collection failed to collect tls variable:"
+ echo " $2"
+ exit 1
+ fi
+
+}
+
+check gc_tls_test.stdout "number"
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 22d5cc6..9287d58 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -2119,7 +2119,6 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
break;
case elfcpp::R_X86_64_DTPOFF32:
- gold_assert(tls_segment != NULL);
if (optimized_type == tls::TLSOPT_TO_LE)
{
// This relocation type is used in debugging information.
@@ -2127,18 +2126,23 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo,
// haven't seen a TLSLD reloc, then we assume we should not
// optimize this reloc.
if (this->saw_tls_block_reloc_)
- value -= tls_segment->memsz();
+ {
+ gold_assert(tls_segment != NULL);
+ value -= tls_segment->memsz();
+ }
}
Relocate_functions<64, false>::rela32(view, value, addend);
break;
case elfcpp::R_X86_64_DTPOFF64:
- gold_assert(tls_segment != NULL);
if (optimized_type == tls::TLSOPT_TO_LE)
{
// See R_X86_64_DTPOFF32, just above, for why we test this.
if (this->saw_tls_block_reloc_)
- value -= tls_segment->memsz();
+ {
+ gold_assert(tls_segment != NULL);
+ value -= tls_segment->memsz();
+ }
}
Relocate_functions<64, false>::rela64(view, value, addend);
break;