From b3705d2a514a4235bd08c02f708f02b1c9285019 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 10 Feb 2010 23:00:29 +0000 Subject: [PATCH] * i386.cc (Relocate::relocate_tls): A local symbol is final if not shared, not if not position independent. * x86_64.cc (Relocate::relocate_tls): Likewise. * testsuite/Makefile.am (check_PROGRAMS): Add tls_pie_pic_test. (tls_pie_pic_test): New target. * testsuite/Makefile.in: Rebuild. --- gold/i386.cc | 7 +++---- gold/testsuite/Makefile.am | 5 +++++ gold/testsuite/Makefile.in | 28 +++++++++++++++++++++++++--- gold/x86_64.cc | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/gold/i386.cc b/gold/i386.cc index f2a7b53f7ad..97d98d724a7 100644 --- a/gold/i386.cc +++ b/gold/i386.cc @@ -1897,10 +1897,9 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo, elfcpp::Elf_types<32>::Elf_Addr value = psymval->value(object, 0); - const bool is_final = - (gsym == NULL - ? !parameters->options().output_is_position_independent() - : gsym->final_value_is_known()); + const bool is_final = (gsym == NULL + ? !parameters->options().shared() + : gsym->final_value_is_known()); const tls::Tls_optimization optimized_type = Target_i386::optimize_tls_reloc(is_final, r_type); switch (r_type) diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index eeb07674f37..1ffb7b05905 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -589,6 +589,7 @@ if TLS check_PROGRAMS += tls_test check_PROGRAMS += tls_pic_test check_PROGRAMS += tls_pie_test +check_PROGRAMS += tls_pie_pic_test check_PROGRAMS += tls_shared_test check_PROGRAMS += tls_shared_ie_test check_PROGRAMS += tls_shared_gd_to_ie_test @@ -638,6 +639,10 @@ tls_pie_test: tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o \ tls_test_c_pie.o gcctestdir/ld $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o -lpthread +tls_pie_pic_test: tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o \ + tls_test_c_pic.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -lpthread + tls_shared_test_SOURCES = tls_test_main.cc tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 41b077be12a..a806b3459de 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -165,6 +165,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__append_10 = tls_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pie_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pie_pic_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_ie_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_gd_to_ie_test @@ -389,6 +390,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pie_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pie_pic_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_ie_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_gd_to_ie_test$(EXEEXT) @@ -760,6 +762,12 @@ am__tls_pic_test_SOURCES_DIST = tls_test_main.cc tls_pic_test_OBJECTS = $(am_tls_pic_test_OBJECTS) tls_pic_test_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(tls_pic_test_LDFLAGS) $(LDFLAGS) -o $@ +tls_pie_pic_test_SOURCES = tls_pie_pic_test.c +tls_pie_pic_test_OBJECTS = tls_pie_pic_test.$(OBJEXT) +tls_pie_pic_test_LDADD = $(LDADD) +tls_pie_pic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \ + ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) tls_pie_test_SOURCES = tls_pie_test.c tls_pie_test_OBJECTS = tls_pie_test.$(OBJEXT) tls_pie_test_LDADD = $(LDADD) @@ -1105,7 +1113,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(script_test_1_SOURCES) $(script_test_2_SOURCES) \ script_test_3.c $(searched_file_test_SOURCES) \ $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \ - $(tls_pic_test_SOURCES) tls_pie_test.c \ + $(tls_pic_test_SOURCES) tls_pie_pic_test.c tls_pie_test.c \ $(tls_shared_gd_to_ie_test_SOURCES) \ $(tls_shared_gnu2_gd_to_ie_test_SOURCES) \ $(tls_shared_gnu2_test_SOURCES) $(tls_shared_ie_test_SOURCES) \ @@ -1168,8 +1176,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ $(am__searched_file_test_SOURCES_DIST) \ $(am__thin_archive_test_1_SOURCES_DIST) \ $(am__thin_archive_test_2_SOURCES_DIST) \ - $(am__tls_pic_test_SOURCES_DIST) tls_pie_test.c \ - $(am__tls_shared_gd_to_ie_test_SOURCES_DIST) \ + $(am__tls_pic_test_SOURCES_DIST) tls_pie_pic_test.c \ + tls_pie_test.c $(am__tls_shared_gd_to_ie_test_SOURCES_DIST) \ $(am__tls_shared_gnu2_gd_to_ie_test_SOURCES_DIST) \ $(am__tls_shared_gnu2_test_SOURCES_DIST) \ $(am__tls_shared_ie_test_SOURCES_DIST) \ @@ -2008,6 +2016,15 @@ thin_archive_test_2$(EXEEXT): $(thin_archive_test_2_OBJECTS) $(thin_archive_test tls_pic_test$(EXEEXT): $(tls_pic_test_OBJECTS) $(tls_pic_test_DEPENDENCIES) @rm -f tls_pic_test$(EXEEXT) $(tls_pic_test_LINK) $(tls_pic_test_OBJECTS) $(tls_pic_test_LDADD) $(LIBS) +@GCC_FALSE@tls_pie_pic_test$(EXEEXT): $(tls_pie_pic_test_OBJECTS) $(tls_pie_pic_test_DEPENDENCIES) +@GCC_FALSE@ @rm -f tls_pie_pic_test$(EXEEXT) +@GCC_FALSE@ $(LINK) $(tls_pie_pic_test_OBJECTS) $(tls_pie_pic_test_LDADD) $(LIBS) +@NATIVE_LINKER_FALSE@tls_pie_pic_test$(EXEEXT): $(tls_pie_pic_test_OBJECTS) $(tls_pie_pic_test_DEPENDENCIES) +@NATIVE_LINKER_FALSE@ @rm -f tls_pie_pic_test$(EXEEXT) +@NATIVE_LINKER_FALSE@ $(LINK) $(tls_pie_pic_test_OBJECTS) $(tls_pie_pic_test_LDADD) $(LIBS) +@TLS_FALSE@tls_pie_pic_test$(EXEEXT): $(tls_pie_pic_test_OBJECTS) $(tls_pie_pic_test_DEPENDENCIES) +@TLS_FALSE@ @rm -f tls_pie_pic_test$(EXEEXT) +@TLS_FALSE@ $(LINK) $(tls_pie_pic_test_OBJECTS) $(tls_pie_pic_test_LDADD) $(LIBS) @GCC_FALSE@tls_pie_test$(EXEEXT): $(tls_pie_test_OBJECTS) $(tls_pie_test_DEPENDENCIES) @GCC_FALSE@ @rm -f tls_pie_test$(EXEEXT) @GCC_FALSE@ $(LINK) $(tls_pie_test_OBJECTS) $(tls_pie_test_LDADD) $(LIBS) @@ -2202,6 +2219,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testmain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thin_archive_main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_pie_pic_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_pie_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_file2.Po@am__quote@ @@ -2786,6 +2804,10 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test_c_pie.o gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pie.o tls_test_file2_pie.o tls_test_c_pie.o -lpthread +@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_pie_pic_test: tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test_c_pic.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -Bgcctestdir/ -pie tls_test_main_pie.o tls_test_pic.o tls_test_file2_pic.o tls_test_c_pic.o -lpthread + @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_GNU2_DIALECT_TRUE@@TLS_TRUE@tls_test_gnu2.o: tls_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_GNU2_DIALECT_TRUE@@TLS_TRUE@ $(CXXCOMPILE) -c -fpic -mtls-dialect=gnu2 -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_GNU2_DIALECT_TRUE@@TLS_TRUE@tls_test_file2_gnu2.o: tls_test_file2.cc diff --git a/gold/x86_64.cc b/gold/x86_64.cc index fea2ec9b914..802d4984e72 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -2053,7 +2053,7 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo, elfcpp::Elf_types<64>::Elf_Addr value = psymval->value(relinfo->object, 0); const bool is_final = (gsym == NULL - ? !parameters->options().output_is_position_independent() + ? !parameters->options().shared() : gsym->final_value_is_known()); const tls::Tls_optimization optimized_type = Target_x86_64::optimize_tls_reloc(is_final, r_type); -- 2.30.2