public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [alpha] allow local-exec tls in PIE images
       [not found] ` <Pine.LNX.4.64.1106221302580.2147@digraph.polyomino.org.uk>
@ 2011-06-22 16:20   ` Richard Henderson
  0 siblings, 0 replies; only message in thread
From: Richard Henderson @ 2011-06-22 16:20 UTC (permalink / raw)
  To: Binutils; +Cc: Joseph S. Myers, Uros Bizjak

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

On 06/22/2011 06:04 AM, Joseph S. Myers wrote:
> On Wed, 22 Jun 2011, Uros Bizjak wrote:
> 
>> Hello!
>>
>> Some -pie TLS tests are unsupported due to "TLS local exec code cannot
>> be linked into shared objects".
> 
> Is there something about the Alpha ABI that makes it impossible to support 
> for PIEs (which are different from shared libraries)?  The conclusion for 
> ARM was that this was a linker bug 
> <http://sourceware.org/ml/binutils/2011-06/msg00204.html>.
> 

Fixing the same bug in the alpha port.


r~

[-- Attachment #2: z --]
[-- Type: text/plain, Size: 3917 bytes --]

        * elf64-alpha.c (elf64_alpha_check_relocs): No dynamic reloc for
        TPREL in a PIE image.
        (alpha_dynamic_entries_for_reloc): Likewise.
        (elf64_alpha_relocate_section): Allow TPREL in PIE images.
        (elf64_alpha_relax_got_load): Likewise.

Index: elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.178
diff -u -p -r1.178 elf64-alpha.c
--- elf64-alpha.c	15 Jun 2011 15:04:12 -0000	1.178
+++ elf64-alpha.c	22 Jun 2011 16:15:28 -0000
@@ -1882,10 +1882,13 @@ elf64_alpha_check_relocs (bfd *abfd, str
 	  break;
 
 	case R_ALPHA_TPREL64:
-	  if (info->shared || maybe_dynamic)
+	  if (info->shared && !info->pie)
+	    {
+	      info->flags |= DF_STATIC_TLS;
+	      need = NEED_DYNREL;
+	    }
+	  else if (maybe_dynamic)
 	    need = NEED_DYNREL;
-	  if (info->shared)
-	    info->flags |= DF_STATIC_TLS;
 	  break;
 	}
 
@@ -2651,7 +2654,7 @@ elf64_alpha_always_size_sections (bfd *o
 /* The number of dynamic relocations required by a static relocation.  */
 
 static int
-alpha_dynamic_entries_for_reloc (int r_type, int dynamic, int shared)
+alpha_dynamic_entries_for_reloc (int r_type, int dynamic, int shared, int pie)
 {
   switch (r_type)
     {
@@ -2661,16 +2664,18 @@ alpha_dynamic_entries_for_reloc (int r_t
     case R_ALPHA_TLSLDM:
       return shared;
     case R_ALPHA_LITERAL:
-    case R_ALPHA_GOTTPREL:
       return dynamic || shared;
+    case R_ALPHA_GOTTPREL:
+      return dynamic || (shared && !pie);
     case R_ALPHA_GOTDTPREL:
       return dynamic;
 
     /* May appear in data sections.  */
     case R_ALPHA_REFLONG:
     case R_ALPHA_REFQUAD:
-    case R_ALPHA_TPREL64:
       return dynamic || shared;
+    case R_ALPHA_TPREL64:
+      return dynamic || (shared && !pie);
 
     /* Everything else is illegal.  We'll issue an error during
        relocate_section.  */
@@ -2718,7 +2723,7 @@ elf64_alpha_calc_dynrel_sizes (struct al
   for (relent = h->reloc_entries; relent; relent = relent->next)
     {
       entries = alpha_dynamic_entries_for_reloc (relent->rtype, dynamic,
-						 info->shared);
+						 info->shared, info->pie);
       if (entries)
 	{
 	  relent->srel->size +=
@@ -2761,8 +2766,8 @@ elf64_alpha_size_rela_got_1 (struct alph
   entries = 0;
   for (gotent = h->got_entries; gotent ; gotent = gotent->next)
     if (gotent->use_count > 0)
-      entries += alpha_dynamic_entries_for_reloc (gotent->reloc_type,
-						  dynamic, info->shared);
+      entries += alpha_dynamic_entries_for_reloc (gotent->reloc_type, dynamic,
+						  info->shared, info->pie);
 
   if (entries > 0)
     {
@@ -2812,7 +2817,7 @@ elf64_alpha_size_rela_got_section (struc
 		 gotent ; gotent = gotent->next)
 	      if (gotent->use_count > 0)
 		entries += (alpha_dynamic_entries_for_reloc
-			    (gotent->reloc_type, 0, info->shared));
+			    (gotent->reloc_type, 0, info->shared, info->pie));
 	}
     }
 
@@ -3044,7 +3049,8 @@ elf64_alpha_relax_got_load (struct alpha
     return TRUE;
 
   /* Can't use local-exec relocations in shared libraries.  */
-  if (r_type == R_ALPHA_GOTTPREL && info->link_info->shared)
+  if (r_type == R_ALPHA_GOTTPREL
+      && (info->link_info->shared && !info->link_info->pie))
     return TRUE;
 
   if (r_type == R_ALPHA_LITERAL)
@@ -4509,7 +4515,7 @@ elf64_alpha_relocate_section (bfd *outpu
 	    else if (r_type == R_ALPHA_TPREL64)
 	      {
 		BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
-		if (!info->shared)
+		if (!info->shared || info->pie)
 		  {
 		    value -= tp_base;
 		    goto default_reloc;
@@ -4630,7 +4636,7 @@ elf64_alpha_relocate_section (bfd *outpu
 	case R_ALPHA_TPRELHI:
 	case R_ALPHA_TPRELLO:
 	case R_ALPHA_TPREL16:
-	  if (info->shared)
+	  if (info->shared && !info->pie)
 	    {
 	      (*_bfd_error_handler)
 		(_("%B: TLS local exec code cannot be linked into shared objects"),

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-22 16:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <BANLkTin5L2RsfYNOfKK7kiY3sgZOdAMiFA@mail.gmail.com>
     [not found] ` <Pine.LNX.4.64.1106221302580.2147@digraph.polyomino.org.uk>
2011-06-22 16:20   ` [alpha] allow local-exec tls in PIE images Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).