+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.
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
# 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 \
# 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 \
@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 \
@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
--- /dev/null
+// 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;
+}
+
--- /dev/null
+#!/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"
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.
// 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;