[PATCH 2/2] bfd/elfnn-aarch64.c: set DF_STATIC_TLS when emitting IE relocs

Alan Modra amodra@gmail.com
Wed Jul 2 04:46:00 GMT 2014


On Tue, Jul 01, 2014 at 12:19:44PM -0400, Kyle McMartin wrote:
> On Wed, Jul 02, 2014 at 01:12:05AM +0930, Alan Modra wrote:
> > DF_STATIC_TLS is a flag that says the object is using thread pointer
> > relative addressing of TLS.  ie. the thread local storage for that
> > object must be laid out at program startup, which means the object
> > can't be dlopen'd (*).  So DF_STATIC_TLS is a flag for objects that
> > might be dlopen'd.  Hmm, and since we can actually dlopen any ET_DYN
> > including PIEs it would seem that info->shared is the correct test.

This corrects powerpc.  I'll leave it to port maintainers to fix arm
and x86.

	* elf32-ppc.c (ppc_elf_check_relocs): Set DF_STATIC_TLS for PIEs too.
	* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.

diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index c4a9543..0a9c8f9 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -4017,7 +4017,7 @@ ppc_elf_check_relocs (bfd *abfd,
 	case R_PPC_GOT_TPREL16_LO:
 	case R_PPC_GOT_TPREL16_HI:
 	case R_PPC_GOT_TPREL16_HA:
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  tls_type = TLS_TLS | TLS_TPREL;
 	  goto dogottls;
@@ -4308,7 +4308,7 @@ ppc_elf_check_relocs (bfd *abfd,
 	case R_PPC_TPREL16_LO:
 	case R_PPC_TPREL16_HI:
 	case R_PPC_TPREL16_HA:
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  goto dodyn;
 
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 267a925..81e54a7 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -5328,7 +5328,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	case R_PPC64_GOT_TPREL16_LO_DS:
 	case R_PPC64_GOT_TPREL16_HI:
 	case R_PPC64_GOT_TPREL16_HA:
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  tls_type = TLS_TLS | TLS_TPREL;
 	  goto dogottls;
@@ -5558,7 +5558,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
 	case R_PPC64_TPREL64:
 	  tls_type = TLS_EXPLICIT | TLS_TLS | TLS_TPREL;
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  goto dotlstoc;
 
@@ -5636,8 +5636,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	case R_PPC64_TPREL16_HIGHESTA:
 	  if (info->shared)
 	    {
-	      if (!info->executable)
-		info->flags |= DF_STATIC_TLS;
+	      info->flags |= DF_STATIC_TLS;
 	      goto dodyn;
 	    }
 	  break;

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list