This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold patch committed: Fix -fpic objects with -pie


There was a small bug in gold with local TLS variables when linking
-fpic objects into -pie executables, at least on i386 and x86_64.  I
committed this patch to add a test case and fix the bug.

Ian


2010-02-10  Ian Lance Taylor  <iant@google.com>

	* 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.


Index: i386.cc
===================================================================
RCS file: /cvs/src/src/gold/i386.cc,v
retrieving revision 1.112
diff -p -u -r1.112 i386.cc
--- i386.cc	9 Feb 2010 20:29:44 -0000	1.112
+++ i386.cc	10 Feb 2010 22:53:11 -0000
@@ -1897,10 +1897,9 @@ Target_i386::Relocate::relocate_tls(cons
 
   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)
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.105
diff -p -u -r1.105 x86_64.cc
--- x86_64.cc	9 Feb 2010 20:29:44 -0000	1.105
+++ x86_64.cc	10 Feb 2010 22:53:11 -0000
@@ -2053,7 +2053,7 @@ Target_x86_64::Relocate::relocate_tls(co
   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);
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.119
diff -p -u -r1.119 Makefile.am
--- testsuite/Makefile.am	10 Feb 2010 22:12:11 -0000	1.119
+++ testsuite/Makefile.am	10 Feb 2010 22:53:11 -0000
@@ -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_te
 		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,.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]