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] Recognize non-PIC calls to __tls_get_addr


When doing link-time optimization, the compiler may decide that it can
generate non-PIC code even for a file that was originally compiled
with -fPIC. This can result in a (GD model) TLS sequence involving a
call to __tls_get_addr, with the actual call to __tls_get_addr using a
non-PIC relocation (R_386_PC32 or R_X86_64_PC32). When doing TLS
relaxation, gold does not expect a non-PIC relocation on this call,
and complains about a "missing expected TLS relocation". This patch
fixes that. Tested with a gcc from the lto branch for both i386 and
x86_64.

-cary


	* i386.cc (Target_i386::Relocate::relocate): Recognize non-PIC calls
	to __tls_get_addr.
	* x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.


Index: i386.cc
===================================================================
RCS file: /cvs/src/src/gold/i386.cc,v
retrieving revision 1.83
diff -u -p -r1.83 i386.cc
--- i386.cc	28 Jan 2009 02:25:33 -0000	1.83
+++ i386.cc	29 Jan 2009 01:30:32 -0000
@@ -1633,7 +1633,8 @@ Target_i386::Relocate::relocate(const Re
 {
   if (this->skip_call_tls_get_addr_)
     {
-      if (r_type != elfcpp::R_386_PLT32
+      if ((r_type != elfcpp::R_386_PLT32
+           && r_type != elfcpp::R_386_PC32)
 	  || gsym == NULL
 	  || strcmp(gsym->name(), "___tls_get_addr") != 0)
 	gold_error_at_location(relinfo, relnum, rel.get_r_offset(),
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.77
diff -u -p -r1.77 x86_64.cc
--- x86_64.cc	28 Jan 2009 02:25:33 -0000	1.77
+++ x86_64.cc	29 Jan 2009 01:30:32 -0000
@@ -1703,7 +1703,8 @@ Target_x86_64::Relocate::relocate(const
 {
   if (this->skip_call_tls_get_addr_)
     {
-      if (r_type != elfcpp::R_X86_64_PLT32
+      if ((r_type != elfcpp::R_X86_64_PLT32
+           && r_type != elfcpp::R_X86_64_PC32)
 	  || gsym == NULL
 	  || strcmp(gsym->name(), "__tls_get_addr") != 0)
 	{


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