OSDN Git Service

* elf32-m68k.c (elf_m68k_copy_indirect_symbol): Propagate non_got_ref
authorNick Clifton <nickc@redhat.com>
Wed, 26 Aug 2009 13:35:36 +0000 (13:35 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 26 Aug 2009 13:35:36 +0000 (13:35 +0000)
        value.
        (elf_m68k_check_relocs): Handle dynamic TLS relocations.
        Handle non_got_ref field.
        (elf_m68k_adjust_dynamic_symbol): Handle non_got_ref field.

        * tls-def-1.s, tls-def-1.d, tls-gd-1.d2, tls-gd-1.d3, tls-main-1.s,
        * tls-main-1.d: New files.
        * m68k.exp: Run new TLS tests.

bfd/ChangeLog
bfd/elf32-m68k.c

index cae2e2f..12966bc 100644 (file)
@@ -1,3 +1,11 @@
+2009-08-26  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       * elf32-m68k.c (elf_m68k_copy_indirect_symbol): Propagate
+       non_got_ref value.
+       (elf_m68k_check_relocs): Handle dynamic TLS relocations.
+       Handle non_got_ref field.
+       (elf_m68k_adjust_dynamic_symbol): Handle non_got_ref field.
+
 2009-08-26  Alan Modra  <amodra@bigpond.net.au>
 
        PR ld/10515
index 2957db0..ced19a1 100644 (file)
@@ -2487,6 +2487,10 @@ elf_m68k_copy_indirect_symbol (struct bfd_link_info *info,
   dir = elf_m68k_hash_entry (_dir);
   ind = elf_m68k_hash_entry (_ind);
 
+  /* Any absolute non-dynamic relocations against an indirect or weak
+     definition will be against the target symbol.  */
+  _dir->non_got_ref |= _ind->non_got_ref;
+
   /* We might have a direct symbol already having entries in the GOTs.
      Update its key only in case indirect symbol has GOT entries and
      assert that both indirect and direct symbols don't have GOT entries
@@ -2581,6 +2585,14 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
        case R_68K_TLS_IE16:
        case R_68K_TLS_IE32:
 
+       case R_68K_TLS_TPREL32:
+       case R_68K_TLS_DTPREL32:
+
+         if (ELF32_R_TYPE (rel->r_info) == R_68K_TLS_TPREL32
+             && info->shared)
+           /* Do the special chorus for libraries with static TLS.  */
+           info->flags |= DF_STATIC_TLS;
+
          /* This symbol requires a global offset table entry.  */
 
          if (dynobj == NULL)
@@ -2739,6 +2751,10 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
              /* Make sure a plt entry is created for this symbol if it
                 turns out to be a function defined by a dynamic object.  */
              h->plt.refcount++;
+
+             if (!info->shared)
+               /* This symbol needs a non-GOT reference.  */
+               h->non_got_ref = 1;
            }
 
          /* If we are creating a shared library, we need to copy the
@@ -2946,6 +2962,9 @@ elf_m68k_gc_sweep_hook (bfd *abfd,
        case R_68K_TLS_IE16:
        case R_68K_TLS_IE32:
 
+       case R_68K_TLS_TPREL32:
+       case R_68K_TLS_DTPREL32:
+
          if (got == NULL)
            {
              got = elf_m68k_get_bfd2got_entry (elf_m68k_multi_got (info),
@@ -3159,6 +3178,11 @@ elf_m68k_adjust_dynamic_symbol (info, h)
   if (info->shared)
     return TRUE;
 
+  /* If there are no references to this symbol that do not use the
+     GOT, we don't need to generate a copy reloc.  */
+  if (!h->non_got_ref)
+    return TRUE;
+
   if (h->size == 0)
     {
       (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),