Make default_mi_gdb_start/dbx_gdb_start use gdb_spawn
[deliverable/binutils-gdb.git] / bfd / elf32-microblaze.c
index 7b839f8c9a0c6fa4f95937ca8539ad4d2fbf0917..1b5c2efcd6edfe372cfcd3fb9b75c251aac2f60d 100644 (file)
@@ -721,9 +721,6 @@ struct elf32_mb_link_hash_entry
 {
   struct elf_link_hash_entry elf;
 
-  /* Track dynamic relocs copied for this symbol.  */
-  struct elf_dyn_relocs *dyn_relocs;
-
   /* TLS Reference Types for the symbol; Updated by check_relocs */
 #define TLS_GD     1  /* GD reloc. */
 #define TLS_LD     2  /* LD reloc. */
@@ -747,9 +744,6 @@ struct elf32_mb_link_hash_table
 {
   struct elf_link_hash_table elf;
 
-  /* Small local sym to section mapping cache.  */
-  struct sym_cache sym_sec;
-
   /* TLS Local Dynamic GOT Entry */
   union {
     bfd_signed_vma refcount;
@@ -762,9 +756,10 @@ struct elf32_mb_link_hash_table
 
 /* Get the ELF linker hash table from a link_info structure.  */
 
-#define elf32_mb_hash_table(p)                         \
-  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
-  == MICROBLAZE_ELF_DATA ? ((struct elf32_mb_link_hash_table *) ((p)->hash)) : NULL)
+#define elf32_mb_hash_table(p) \
+  ((is_elf_hash_table ((p)->hash)                                      \
+    && elf_hash_table_id (elf_hash_table (p)) == MICROBLAZE_ELF_DATA)  \
+   ? (struct elf32_mb_link_hash_table *) (p)->hash : NULL)
 
 /* Create an entry in a microblaze ELF linker hash table.  */
 
@@ -790,7 +785,6 @@ link_hash_newfunc (struct bfd_hash_entry *entry,
       struct elf32_mb_link_hash_entry *eh;
 
       eh = (struct elf32_mb_link_hash_entry *) entry;
-      eh->dyn_relocs = NULL;
       eh->tls_mask = 0;
     }
 
@@ -803,7 +797,7 @@ static struct bfd_link_hash_table *
 microblaze_elf_link_hash_table_create (bfd *abfd)
 {
   struct elf32_mb_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct elf32_mb_link_hash_table);
+  size_t amt = sizeof (struct elf32_mb_link_hash_table);
 
   ret = (struct elf32_mb_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
@@ -2234,11 +2228,8 @@ microblaze_elf_relax_section (bfd *abfd,
       symtab_hdr->contents = (bfd_byte *) isymbuf;
     }
 
-  if (free_relocs != NULL)
-    {
-      free (free_relocs);
-      free_relocs = NULL;
-    }
+  free (free_relocs);
+  free_relocs = NULL;
 
   if (free_contents != NULL)
     {
@@ -2261,16 +2252,11 @@ microblaze_elf_relax_section (bfd *abfd,
   return TRUE;
 
  error_return:
-  if (free_relocs != NULL)
-    free (free_relocs);
-  if (free_contents != NULL)
-    free (free_contents);
-  if (sec->relax != NULL)
-    {
-      free (sec->relax);
-      sec->relax = NULL;
-      sec->relax_count = 0;
-    }
+  free (free_relocs);
+  free (free_contents);
+  free (sec->relax);
+  sec->relax = NULL;
+  sec->relax_count = 0;
   return FALSE;
 }
 
@@ -2524,7 +2510,7 @@ microblaze_elf_check_relocs (bfd * abfd,
                /* If this is a global symbol, we count the number of
                   relocations we need for this symbol.  */
                if (h != NULL)
-                 head = &((struct elf32_mb_link_hash_entry *) h)->dyn_relocs;
+                 head = &h->dyn_relocs;
                else
                  {
                    /* Track dynamic relocs needed for local syms too.
@@ -2535,7 +2521,7 @@ microblaze_elf_check_relocs (bfd * abfd,
                    Elf_Internal_Sym *isym;
                    void *vpp;
 
-                   isym = bfd_sym_from_r_symndx (&htab->sym_sec,
+                   isym = bfd_sym_from_r_symndx (&htab->elf.sym_cache,
                                                  abfd, r_symndx);
                    if (isym == NULL)
                      return FALSE;
@@ -2551,7 +2537,7 @@ microblaze_elf_check_relocs (bfd * abfd,
                p = *head;
                if (p == NULL || p->sec != sec)
                  {
-                   bfd_size_type amt = sizeof *p;
+                   size_t amt = sizeof *p;
                    p = ((struct elf_dyn_relocs *)
                         bfd_alloc (htab->elf.dynobj, amt));
                    if (p == NULL)
@@ -2587,62 +2573,11 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
   edir = (struct elf32_mb_link_hash_entry *) dir;
   eind = (struct elf32_mb_link_hash_entry *) ind;
 
-  if (eind->dyn_relocs != NULL)
-    {
-      if (edir->dyn_relocs != NULL)
-       {
-         struct elf_dyn_relocs **pp;
-         struct elf_dyn_relocs *p;
-
-         if (ind->root.type == bfd_link_hash_indirect)
-           abort ();
-
-         /* Add reloc counts against the weak sym to the strong sym
-            list.  Merge any entries against the same section.  */
-         for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
-           {
-             struct elf_dyn_relocs *q;
-
-             for (q = edir->dyn_relocs; q != NULL; q = q->next)
-               if (q->sec == p->sec)
-                 {
-                   q->pc_count += p->pc_count;
-                   q->count += p->count;
-                   *pp = p->next;
-                   break;
-                 }
-             if (q == NULL)
-               pp = &p->next;
-           }
-         *pp = edir->dyn_relocs;
-       }
-
-      edir->dyn_relocs = eind->dyn_relocs;
-      eind->dyn_relocs = NULL;
-    }
-
   edir->tls_mask |= eind->tls_mask;
 
   _bfd_elf_link_hash_copy_indirect (info, dir, ind);
 }
 
-/* Find dynamic relocs for H that apply to read-only sections.  */
-
-static asection *
-readonly_dynrelocs (struct elf_link_hash_entry *h)
-{
-  struct elf_dyn_relocs *p;
-
-  for (p = elf32_mb_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
-    {
-      asection *s = p->sec->output_section;
-
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       return p->sec;
-    }
-  return NULL;
-}
-
 static bfd_boolean
 microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
                                      struct elf_link_hash_entry *h)
@@ -2721,7 +2656,7 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 
   /* If we don't find any dynamic relocs in read-only sections, then
      we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-  if (!readonly_dynrelocs (h))
+  if (!_bfd_elf_readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
@@ -2906,7 +2841,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
   else
     h->got.offset = (bfd_vma) -1;
 
-  if (eh->dyn_relocs == NULL)
+  if (h->dyn_relocs == NULL)
     return TRUE;
 
   /* In the shared -Bsymbolic case, discard space allocated for
@@ -2923,7 +2858,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
        {
          struct elf_dyn_relocs **pp;
 
-         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+         for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
            {
              p->count -= p->pc_count;
              p->pc_count = 0;
@@ -2934,7 +2869,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
            }
        }
       else if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
-       eh->dyn_relocs = NULL;
+       h->dyn_relocs = NULL;
     }
   else
     {
@@ -2964,13 +2899,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
            goto keep;
        }
 
-      eh->dyn_relocs = NULL;
+      h->dyn_relocs = NULL;
 
     keep: ;
     }
 
   /* Finally, allocate space.  */
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+  for (p = h->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc = elf_section_data (p->sec)->sreloc;
       sreloc->size += p->count * sizeof (Elf32_External_Rela);
@@ -3166,45 +3101,9 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        return FALSE;
     }
 
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-        values later, in microblaze_elf_finish_dynamic_sections, but we
-        must add the entries now so that we get the correct size for
-        the .dynamic section.  The DT_DEBUG entry is filled in by the
-        dynamic linker and used by the debugger.  */
-#define add_dynamic_entry(TAG, VAL)                    \
-      _bfd_elf_add_dynamic_entry (info, TAG, VAL)
-
-      if (bfd_link_executable (info))
-       {
-         if (!add_dynamic_entry (DT_DEBUG, 0))
-           return FALSE;
-       }
-
-      if (!add_dynamic_entry (DT_RELA, 0)
-         || !add_dynamic_entry (DT_RELASZ, 0)
-         || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
-       return FALSE;
-
-      if (htab->elf.splt->size != 0)
-       {
-         if (!add_dynamic_entry (DT_PLTGOT, 0)
-             || !add_dynamic_entry (DT_PLTRELSZ, 0)
-             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
-             || !add_dynamic_entry (DT_JMPREL, 0)
-             || !add_dynamic_entry (DT_BIND_NOW, 1))
-           return FALSE;
-       }
-
-      if (info->flags & DF_TEXTREL)
-       {
-         if (!add_dynamic_entry (DT_TEXTREL, 0))
-           return FALSE;
-       }
-    }
-#undef add_dynamic_entry
-  return TRUE;
+  /* ??? Force DF_BIND_NOW?  */
+  info->flags |= DF_BIND_NOW;
+  return _bfd_elf_add_dynamic_tags (output_bfd, info, TRUE);
 }
 
 /* Finish up dynamic symbol handling.  We set the contents of various
@@ -3501,7 +3400,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
         put into .sbss.  */
       *secp = bfd_make_section_old_way (abfd, ".sbss");
       if (*secp == NULL
-         || !bfd_set_section_flags (*secp, SEC_IS_COMMON))
+         || !bfd_set_section_flags (*secp, SEC_IS_COMMON | SEC_SMALL_DATA))
        return FALSE;
 
       *valp = sym->st_size;
This page took 0.034437 seconds and 4 git commands to generate.