[committed] Fix various TLS relocations in non-shared links

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Jan 30 16:20:00 GMT 2010

When doing non-shared links, we need to fix various TLS relocations
to use the global data pointer when the code was originally compiled
as PIC code.

Tested with no regressions on hppa-unknown-linux-gnu.

J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2010-01-30  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* elf32-hppa.c (final_link_relocate): Convert R_PARISC_TLS_GD21L,
	R_PARISC_TLS_LDM21L and R_PARISC_TLS_IE21L relocations that use the
	linkage table pointer to use the global table pointer if not doing
	a shared link.

Index: elf32-hppa.c
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.169
diff -u -3 -p -r1.169 elf32-hppa.c
--- elf32-hppa.c	8 Nov 2009 20:47:24 -0000	1.169
+++ elf32-hppa.c	26 Jan 2010 02:52:02 -0000
@@ -3388,12 +3388,19 @@ final_link_relocate (asection *input_sec
     case R_PARISC_DPREL21L:
     case R_PARISC_DPREL14R:
     case R_PARISC_DPREL14F:
+    case R_PARISC_TLS_GD21L:
+    case R_PARISC_TLS_LDM21L:
+    case R_PARISC_TLS_IE21L:
       /* Convert instructions that use the linkage table pointer (r19) to
 	 instructions that use the global data pointer (dp).  This is the
 	 most efficient way of using PIC code in an incomplete executable,
 	 but the user must follow the standard runtime conventions for
 	 accessing data for this to work.  */
-      if (orig_r_type == R_PARISC_DLTIND21L)
+      if (orig_r_type == R_PARISC_DLTIND21L
+	  || (!info->shared
+	      && (r_type == R_PARISC_TLS_GD21L
+		  || r_type == R_PARISC_TLS_LDM21L
+		  || r_type == R_PARISC_TLS_IE21L)))
 	  /* Convert addil instructions if the original reloc was a
 	     DLTIND21L.  GCC sometimes uses a register other than r19 for
@@ -3444,11 +3451,8 @@ final_link_relocate (asection *input_sec
     case R_PARISC_DLTIND21L:
     case R_PARISC_DLTIND14R:
     case R_PARISC_DLTIND14F:
-    case R_PARISC_TLS_GD21L:
     case R_PARISC_TLS_GD14R:
-    case R_PARISC_TLS_LDM21L:
     case R_PARISC_TLS_LDM14R:
-    case R_PARISC_TLS_IE21L:
     case R_PARISC_TLS_IE14R:
       value -= elf_gp (input_section->output_section->owner);

More information about the Binutils mailing list