PR ld/15056
[deliverable/binutils-gdb.git] / bfd / elf32-tilepro.c
index cbb65c6b1a48405fe14ad2492ec3c5404b666b51..db37403b7f8c17736125bce6b258fc1af917cb58 100644 (file)
@@ -737,6 +737,16 @@ struct _bfd_tilepro_elf_obj_tdata
    && elf_tdata (bfd) != NULL                          \
    && elf_object_id (bfd) == TILEPRO_ELF_DATA)
 
+/* Allocate TILEPro ELF private object data.  */
+
+static bfd_boolean
+tilepro_elf_mkobject (bfd *abfd)
+{
+  return bfd_elf_allocate_object (abfd,
+                                 sizeof (struct _bfd_tilepro_elf_obj_tdata),
+                                 TILEPRO_ELF_DATA);
+}
+
 #include "elf/common.h"
 #include "elf/internal.h"
 
@@ -1858,11 +1868,33 @@ tilepro_elf_gc_mark_hook (asection *sec,
   if (h != NULL)
     {
       switch (ELF32_R_TYPE (rel->r_info))
-      {
-      case R_TILEPRO_GNU_VTINHERIT:
-      case R_TILEPRO_GNU_VTENTRY:
-       break;
-      }
+       {
+       case R_TILEPRO_GNU_VTINHERIT:
+       case R_TILEPRO_GNU_VTENTRY:
+         return NULL;
+       }
+    }
+
+  /* FIXME: The test here, in check_relocs and in relocate_section
+     dealing with TLS optimization, ought to be !info->executable.  */
+  if (info->shared)
+    {
+      switch (ELF32_R_TYPE (rel->r_info))
+       {
+       case R_TILEPRO_TLS_GD_CALL:
+         /* This reloc implicitly references __tls_get_addr.  We know
+            another reloc will reference the same symbol as the one
+            on this reloc, so the real symbol and section will be
+            gc marked when processing the other reloc.  That lets
+            us handle __tls_get_addr here.  */
+         h = elf_link_hash_lookup (elf_hash_table (info), "__tls_get_addr",
+                                   FALSE, FALSE, TRUE);
+         BFD_ASSERT (h != NULL);
+         h->mark = 1;
+         if (h->u.weakdef != NULL)
+           h->u.weakdef->mark = 1;
+         sym = NULL;
+       }
     }
 
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
@@ -3092,7 +3124,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                  local_got_offsets[r_symndx] |= 1;
                }
            }
-         relocation = htab->elf.sgot->output_offset + off - got_base;
+         relocation = off - got_base;
          break;
 
         case R_TILEPRO_JOFFLONG_X1_PLT:
@@ -3511,7 +3543,7 @@ tilepro_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
          if (off >= (bfd_vma) -2)
            abort ();
 
-         relocation = htab->elf.sgot->output_offset + off - got_base;
+         relocation = off - got_base;
          unresolved_reloc = FALSE;
          howto = tilepro_elf_howto_table + r_type;
          break;
@@ -4008,6 +4040,8 @@ tilepro_additional_program_headers (bfd *abfd,
 #define elf_backend_grok_psinfo              tilepro_elf_grok_psinfo
 #define elf_backend_additional_program_headers tilepro_additional_program_headers
 
+#define bfd_elf32_mkobject                  tilepro_elf_mkobject
+
 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
 
 #define elf_backend_can_gc_sections 1
This page took 0.025567 seconds and 4 git commands to generate.