[4/7,BZ,#17078] arm: remove prelinker support for R_ARM_TLS_DESC

Message ID 59EF4E31.8060201@arm.com
State New, archived
Headers

Commit Message

Szabolcs Nagy Oct. 24, 2017, 2:29 p.m. UTC
  2017-10-23  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	[BZ #17078]
	* sysdeps/arm/dl-machine.h (elf_machine_rela): Remove the
	R_ARM_TLS_DESC case.
	(elf_machine_lazy_rel): Remove the prelink check.
  

Patch

From dbe01dbadd47a6f406bba6feb2cedd6840af0fc7 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Fri, 20 Oct 2017 17:10:50 +0100
Subject: [PATCH 4/7] [BZ #17078] arm: remove prelinker support for
 R_ARM_TLS_DESC

This patch reverts

commit 9c82da17b5794efebe005de2fd22d61a3ea4b58a
Author: Maciej W. Rozycki <macro@codesourcery.com>
Date:   2014-07-17 19:22:05 +0100

    [BZ #17078] ARM: R_ARM_TLS_DESC prelinker support

This only implemented support for the lazy binding case (and thus
closed the bugzilla ticket prematurely), however tlsdesc on arm is
not correct with lazy binding because there is a data race between
the lazy initialization code and tlsdesc resolver functions.

Lazy initialization of tlsdesc entries will be removed from arm to
fix the data races and thus this half-finished prelinker support
is no longer useful.

	[BZ #17078]
	* sysdeps/arm/dl-machine.h (elf_machine_rela): Remove the
	R_ARM_TLS_DESC case.
	(elf_machine_lazy_rel): Remove the prelink check.
---
 sysdeps/arm/dl-machine.h | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index 7e2d73e3d4..bf5f5d205c 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -594,32 +594,6 @@  elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
 	case R_ARM_ABS32:
 	  *reloc_addr = value + reloc->r_addend;
 	  break;
-#  ifdef RESOLVE_CONFLICT_FIND_MAP
-	case R_ARM_TLS_DESC:
-	  {
-	    struct tlsdesc volatile *td __attribute__ ((unused)) =
-	      (struct tlsdesc volatile *) reloc_addr;
-
-	    RESOLVE_CONFLICT_FIND_MAP (map, reloc_addr);
-
-	    /* Make sure we know what's going on.  */
-	    assert (td->entry
-		    == (void *) (D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)])
-				 + map->l_addr));
-	    assert (map->l_info[ADDRIDX (DT_TLSDESC_GOT)]);
-
-	    /* Set up the lazy resolver and store the pointer to our link
-	       map in _GLOBAL_OFFSET_TABLE[1] now as for a prelinked
-	       binary elf_machine_runtime_setup() is not called and hence
-	       neither has been initialized.  */
-	    *(Elf32_Addr *) (D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_GOT)])
-			     + map->l_addr)
-	      = (Elf32_Addr) &_dl_tlsdesc_lazy_resolver;
-	    ((Elf32_Addr *) D_PTR (map, l_info[DT_PLTGOT]))[1]
-	      = (Elf32_Addr) map;
-	  }
-	  break;
-#  endif /* RESOLVE_CONFLICT_FIND_MAP */
 	case R_ARM_PC24:
           relocate_pc24 (map, value, reloc_addr, reloc->r_addend);
 	  break;
@@ -699,11 +673,9 @@  elf_machine_lazy_rel (struct link_map *map,
 	(struct tlsdesc volatile *)reloc_addr;
 
       /* The linker must have given us the parameter we need in the
-	 first GOT entry, and left the second one empty.  The latter
-	 will have been preset by the prelinker if used though.
-	 We fill it with the resolver address.  */
-      assert (td->entry == 0
-	      || map->l_info[VALIDX (DT_GNU_PRELINKED)] != NULL);
+	 first GOT entry, and left the second one empty.  We fill the
+	 latter with the resolver address.  */
+      assert (td->entry == 0);
       td->entry = (void*)(D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)])
 			  + map->l_addr);
     }
-- 
2.11.0