+2017-12-06  Alan Modra  <amodra@gmail.com>
+
+       * elf32-hppa.c (struct elf32_hppa_dyn_reloc_entry): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (elf32_hppa_adjust_dynamic_symbol): Comment tidy.
+       * elf32-lm32.c (struct elf_lm32_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (lm32_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elf32-m32r.c (struct elf_m32r_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (m32r_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
+       Disable -z no-copyreloc too.
+       * elf32-metag.c (struct elf_metag_dyn_reloc_entry): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (elf_metag_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elf32-microblaze.c (struct elf32_mb_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (readonly_dynrelocs): New function.
+       (microblaze_elf_adjust_dynamic_symbol): Use it.
+       * elf32-nds32.c (struct elf_nds32_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (nds32_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
+       Disable -z no-copyreloc too.
+       * elf32-nios2.c (struct elf32_nios2_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       * elf32-or1k.c (struct elf_or1k_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (or1k_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elf32-sh.c (struct elf_sh_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (sh_elf_adjust_dynamic_symbol): Use readonly_dynrelocs, but disable.
+       Disable -z no-copyreloc too.
+       * elf32-tilepro.c (struct tilepro_elf_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (tilepro_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elfnn-riscv.c (struct riscv_elf_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (riscv_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elfxx-sparc.c (struct _bfd_sparc_elf_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (_bfd_sparc_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elfxx-tilegx.c (struct tilegx_elf_dyn_relocs): Delete.  Use
+       struct elf_dyn_relocs throughout file instead.
+       (tilegx_elf_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elf32-s390.c (elf_s390_adjust_dynamic_symbol): Use readonly_dynrelocs.
+       * elf64-s390.c (elf_s390_adjust_dynamic_symbol): Use readonly_dynrelocs.
+
 2017-12-06  Alan Modra  <amodra@gmail.com>
 
        * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Comment tidy.
 
    bfd_hash_table containing stubs     "bstab"
    elf32_hppa_stub_hash_entry          "hsh"
 
-   elf32_hppa_dyn_reloc_entry          "hdh"
-
    Always remember to use GNU Coding Style. */
 
 #define PLT_ENTRY_SIZE 8
 
   /* Used to count relocations for delayed sizing of relocation
      sections.  */
-  struct elf32_hppa_dyn_reloc_entry
-  {
-    /* Next relocation in the chain.  */
-    struct elf32_hppa_dyn_reloc_entry *hdh_next;
-
-    /* The input section of the reloc.  */
-    asection *sec;
-
-    /* Number of relocs copied in this section.  */
-    bfd_size_type count;
-
-#if RELATIVE_DYNRELOCS
-  /* Number of relative relocs copied for the input section.  */
-    bfd_size_type relative_count;
-#endif
-  } *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   ENUM_BITFIELD (_tls_type) tls_type : 8;
 
     {
       if (hh_dir->dyn_relocs != NULL)
        {
-         struct elf32_hppa_dyn_reloc_entry **hdh_pp;
-         struct elf32_hppa_dyn_reloc_entry *hdh_p;
+         struct elf_dyn_relocs **hdh_pp;
+         struct elf_dyn_relocs *hdh_p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (hdh_pp = &hh_ind->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
            {
-             struct elf32_hppa_dyn_reloc_entry *hdh_q;
+             struct elf_dyn_relocs *hdh_q;
 
              for (hdh_q = hh_dir->dyn_relocs;
                   hdh_q != NULL;
-                  hdh_q = hdh_q->hdh_next)
+                  hdh_q = hdh_q->next)
                if (hdh_q->sec == hdh_p->sec)
                  {
 #if RELATIVE_DYNRELOCS
-                   hdh_q->relative_count += hdh_p->relative_count;
+                   hdh_q->pc_count += hdh_p->pc_count;
 #endif
                    hdh_q->count += hdh_p->count;
-                   *hdh_pp = hdh_p->hdh_next;
+                   *hdh_pp = hdh_p->next;
                    break;
                  }
              if (hdh_q == NULL)
-               hdh_pp = &hdh_p->hdh_next;
+               hdh_pp = &hdh_p->next;
            }
          *hdh_pp = hh_dir->dyn_relocs;
        }
                  && (hh->eh.root.type == bfd_link_hash_defweak
                      || !hh->eh.def_regular)))
            {
-             struct elf32_hppa_dyn_reloc_entry *hdh_p;
-             struct elf32_hppa_dyn_reloc_entry **hdh_head;
+             struct elf_dyn_relocs *hdh_p;
+             struct elf_dyn_relocs **hdh_head;
 
              /* Create a reloc section in dynobj and make room for
                 this reloc.  */
                    sr = sec;
 
                  vpp = &elf_section_data (sr)->local_dynrel;
-                 hdh_head = (struct elf32_hppa_dyn_reloc_entry **) vpp;
+                 hdh_head = (struct elf_dyn_relocs **) vpp;
                }
 
              hdh_p = *hdh_head;
                  hdh_p = bfd_alloc (htab->etab.dynobj, sizeof *hdh_p);
                  if (hdh_p == NULL)
                    return FALSE;
-                 hdh_p->hdh_next = *hdh_head;
+                 hdh_p->next = *hdh_head;
                  *hdh_head = hdh_p;
                  hdh_p->sec = sec;
                  hdh_p->count = 0;
 #if RELATIVE_DYNRELOCS
-                 hdh_p->relative_count = 0;
+                 hdh_p->pc_count = 0;
 #endif
                }
 
              hdh_p->count += 1;
 #if RELATIVE_DYNRELOCS
              if (!IS_ABSOLUTE_RELOC (rtype))
-               hdh_p->relative_count += 1;
+               hdh_p->pc_count += 1;
 #endif
            }
        }
 readonly_dynrelocs (struct elf_link_hash_entry *eh)
 {
   struct elf32_hppa_link_hash_entry *hh;
-  struct elf32_hppa_dyn_reloc_entry *hdh_p;
+  struct elf_dyn_relocs *hdh_p;
 
   hh = hppa_elf_hash_entry (eh);
-  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
+  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->next)
     {
       asection *sec = hdh_p->sec->output_section;
 
   if (info->nocopyreloc)
     return TRUE;
 
+  /* 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 (ELIMINATE_COPY_RELOCS
       && !alias_readonly_dynrelocs (eh))
-    {
-      /* If we didn't find any dynamic relocs in read-only sections, then
-        we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-      return TRUE;
-    }
+    return TRUE;
 
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
   struct elf32_hppa_link_hash_table *htab;
   asection *sec;
   struct elf32_hppa_link_hash_entry *hh;
-  struct elf32_hppa_dyn_reloc_entry *hdh_p;
+  struct elf_dyn_relocs *hdh_p;
 
   if (eh->root.type == bfd_link_hash_indirect)
     return TRUE;
 #if RELATIVE_DYNRELOCS
       if (SYMBOL_CALLS_LOCAL (info, eh))
        {
-         struct elf32_hppa_dyn_reloc_entry **hdh_pp;
+         struct elf_dyn_relocs **hdh_pp;
 
          for (hdh_pp = &hh->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
            {
-             hdh_p->count -= hdh_p->relative_count;
-             hdh_p->relative_count = 0;
+             hdh_p->count -= hdh_p->pc_count;
+             hdh_p->pc_count = 0;
              if (hdh_p->count == 0)
-               *hdh_pp = hdh_p->hdh_next;
+               *hdh_pp = hdh_p->next;
              else
-               hdh_pp = &hdh_p->hdh_next;
+               hdh_pp = &hdh_p->next;
            }
        }
 #endif
     }
 
   /* Finally, allocate space.  */
-  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
+  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->next)
     {
       asection *sreloc = elf_section_data (hdh_p->sec)->sreloc;
       sreloc->size += hdh_p->count * sizeof (Elf32_External_Rela);
 
       for (sec = ibfd->sections; sec != NULL; sec = sec->next)
        {
-         struct elf32_hppa_dyn_reloc_entry *hdh_p;
+         struct elf_dyn_relocs *hdh_p;
 
-         for (hdh_p = ((struct elf32_hppa_dyn_reloc_entry *)
+         for (hdh_p = ((struct elf_dyn_relocs *)
                    elf_section_data (sec)->local_dynrel);
               hdh_p != NULL;
-              hdh_p = hdh_p->hdh_next)
+              hdh_p = hdh_p->next)
            {
              if (!bfd_is_abs_section (hdh_p->sec)
                  && bfd_is_abs_section (hdh_p->sec->output_section))
 
 static bfd_reloc_status_type lm32_elf_gprel_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 
-/* The linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_lm32_dyn_relocs
-{
-  struct elf_lm32_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* lm32 ELF linker hash entry.  */
 
 struct elf_lm32_link_hash_entry
   struct elf_link_hash_entry root;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_lm32_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 };
 
 /* lm32 ELF linker hash table.  */
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct elf_lm32_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
   struct elf_lm32_link_hash_entry *eh = (struct elf_lm32_link_hash_entry *) h;
 
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
                                struct elf_link_hash_entry *h)
 {
   struct elf_lm32_link_hash_table *htab;
-  struct elf_lm32_link_hash_entry *eh;
-  struct elf_lm32_dyn_relocs *p;
   bfd *dynobj;
   asection *s;
 
     return TRUE;
 
   /* If -z nocopyreloc was given, we won't generate them either.  */
-  if (info->nocopyreloc)
+  if (0 && info->nocopyreloc)
     {
       h->non_got_ref = 0;
       return TRUE;
     }
 
-  eh = (struct elf_lm32_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0)
-        break;
-    }
-
-  /* If we didn't find any dynamic relocs in sections which needs the
-     copy reloc, then we'll be keeping the dynamic relocs and avoiding
-     the copy reloc.  */
-  if (p == NULL)
+  /* 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 (0 && !readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf_lm32_link_hash_table *htab;
   struct elf_lm32_link_hash_entry *eh;
-  struct elf_lm32_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
           && (h->forced_local
               || info->symbolic))
         {
-          struct elf_lm32_dyn_relocs **pp;
+          struct elf_dyn_relocs **pp;
 
           for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
             {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
         {
-          struct elf_lm32_dyn_relocs *p;
+          struct elf_dyn_relocs *p;
 
-          for (p = ((struct elf_lm32_dyn_relocs *)
+          for (p = ((struct elf_dyn_relocs *)
                     elf_section_data (s)->local_dynrel);
                p != NULL;
                p = p->next)
     {
       if (edir->dyn_relocs != NULL)
         {
-          struct elf_lm32_dyn_relocs **pp;
-          struct elf_lm32_dyn_relocs *p;
+          struct elf_dyn_relocs **pp;
+          struct elf_dyn_relocs *p;
 
           /* Add reloc counts against the indirect sym to the direct sym
              list.  Merge any entries against the same section.  */
           for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
             {
-              struct elf_lm32_dyn_relocs *q;
+              struct elf_dyn_relocs *q;
 
               for (q = edir->dyn_relocs; q != NULL; q = q->next)
                 if (q->sec == p->sec)
 
   bfd_size_type count;
 };
 
-/* The sh linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_m32r_dyn_relocs
-{
-  struct elf_m32r_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
-
 /* m32r ELF linker hash entry.  */
 
 struct elf_m32r_link_hash_entry
   struct elf_link_hash_entry root;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_m32r_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 };
 
 /* m32r ELF linker hash table.  */
     {
       if (edir->dyn_relocs != NULL)
         {
-          struct elf_m32r_dyn_relocs **pp;
-          struct elf_m32r_dyn_relocs *p;
+          struct elf_dyn_relocs **pp;
+          struct elf_dyn_relocs *p;
 
           /* Add reloc counts against the indirect sym to the direct sym
              list.  Merge any entries against the same section.  */
           for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
             {
-              struct elf_m32r_dyn_relocs *q;
+              struct elf_dyn_relocs *q;
 
               for (q = edir->dyn_relocs; q != NULL; q = q->next)
                 if (q->sec == p->sec)
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct elf_m32r_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
   struct elf_m32r_link_hash_entry *eh = (struct elf_m32r_link_hash_entry *) h;
 
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
                                struct elf_link_hash_entry *h)
 {
   struct elf_m32r_link_hash_table *htab;
-  struct elf_m32r_link_hash_entry *eh;
-  struct elf_m32r_dyn_relocs *p;
   bfd *dynobj;
   asection *s;
 
     return TRUE;
 
   /* If -z nocopyreloc was given, we won't generate them either.  */
-  if (info->nocopyreloc)
+  if (0 && info->nocopyreloc)
     {
       h->non_got_ref = 0;
       return TRUE;
     }
 
-  eh = (struct elf_m32r_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0)
-        break;
-    }
-
-  /* If we didn't find any dynamic relocs in sections which needs the
-     copy reloc, then we'll be keeping the dynamic relocs and avoiding
-     the copy reloc.  */
-  if (p == NULL)
+  /* 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 (0 && !readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf_m32r_link_hash_table *htab;
   struct elf_m32r_link_hash_entry *eh;
-  struct elf_m32r_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
           && (h->forced_local
               || info->symbolic))
         {
-          struct elf_m32r_dyn_relocs **pp;
+          struct elf_dyn_relocs **pp;
 
           for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
             {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
         {
-          struct elf_m32r_dyn_relocs *p;
+          struct elf_dyn_relocs *p;
 
-          for (p = ((struct elf_m32r_dyn_relocs *)
+          for (p = ((struct elf_dyn_relocs *)
                     elf_section_data (s)->local_dynrel);
                p != NULL;
                p = p->next)
                   && (h->root.type == bfd_link_hash_defweak
                       || !h->def_regular)))
             {
-              struct elf_m32r_dyn_relocs *p;
-              struct elf_m32r_dyn_relocs **head;
+              struct elf_dyn_relocs *p;
+              struct elf_dyn_relocs **head;
 
               if (dynobj == NULL)
                 htab->root.dynobj = dynobj = abfd;
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                  head = (struct elf_m32r_dyn_relocs **) vpp;
+                  head = (struct elf_dyn_relocs **) vpp;
                 }
 
               p = *head;
 
    bfd_hash_table containing stubs "bstab"
    elf_metag_stub_hash_entry       "hsh"
 
-   elf_metag_dyn_reloc_entry       "hdh"
-
    Always remember to use GNU Coding Style.  */
 
 #define PLT_ENTRY_SIZE sizeof(plt_entry)
 
   /* Used to count relocations for delayed sizing of relocation
      sections.  */
-  struct elf_metag_dyn_reloc_entry {
-
-    /* Next relocation in the chain.  */
-    struct elf_metag_dyn_reloc_entry *hdh_next;
-
-    /* The input section of the reloc.  */
-    asection *sec;
-
-    /* Number of relocs copied in this section.  */
-    bfd_size_type count;
-
-    /* Number of relative relocs copied for the input section.  */
-    bfd_size_type relative_count;
-  } *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   enum
     {
                  && (hh->eh.root.type == bfd_link_hash_defweak
                      || !hh->eh.def_regular)))
            {
-             struct elf_metag_dyn_reloc_entry *hdh_p;
-             struct elf_metag_dyn_reloc_entry **hdh_head;
+             struct elf_dyn_relocs *hdh_p;
+             struct elf_dyn_relocs **hdh_head;
 
              if (dynobj == NULL)
                htab->etab.dynobj = dynobj = abfd;
                    sr = sec;
 
                  vpp = &elf_section_data (sr)->local_dynrel;
-                 hdh_head = (struct elf_metag_dyn_reloc_entry **) vpp;
+                 hdh_head = (struct elf_dyn_relocs **) vpp;
                }
 
              hdh_p = *hdh_head;
              if (hdh_p == NULL || hdh_p->sec != sec)
                {
-                 hdh_p = ((struct elf_metag_dyn_reloc_entry *)
+                 hdh_p = ((struct elf_dyn_relocs *)
                           bfd_alloc (dynobj, sizeof *hdh_p));
                  if (hdh_p == NULL)
                    return FALSE;
-                 hdh_p->hdh_next = *hdh_head;
+                 hdh_p->next = *hdh_head;
                  *hdh_head = hdh_p;
                  hdh_p->sec = sec;
                  hdh_p->count = 0;
-                 hdh_p->relative_count = 0;
+                 hdh_p->pc_count = 0;
                }
 
              hdh_p->count += 1;
              if (ELF32_R_TYPE (rel->r_info) == R_METAG_RELBRANCH)
-               hdh_p->relative_count += 1;
+               hdh_p->pc_count += 1;
            }
          break;
 
     {
       if (hh_dir->dyn_relocs != NULL)
        {
-         struct elf_metag_dyn_reloc_entry **hdh_pp;
-         struct elf_metag_dyn_reloc_entry *hdh_p;
+         struct elf_dyn_relocs **hdh_pp;
+         struct elf_dyn_relocs *hdh_p;
 
          if (eh_ind->root.type == bfd_link_hash_indirect)
            abort ();
             list.  Merge any entries against the same section.  */
          for (hdh_pp = &hh_ind->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
            {
-             struct elf_metag_dyn_reloc_entry *hdh_q;
+             struct elf_dyn_relocs *hdh_q;
 
              for (hdh_q = hh_dir->dyn_relocs; hdh_q != NULL;
-                  hdh_q = hdh_q->hdh_next)
+                  hdh_q = hdh_q->next)
                if (hdh_q->sec == hdh_p->sec)
                  {
-                   hdh_q->relative_count += hdh_p->relative_count;
+                   hdh_q->pc_count += hdh_p->pc_count;
                    hdh_q->count += hdh_p->count;
-                   *hdh_pp = hdh_p->hdh_next;
+                   *hdh_pp = hdh_p->next;
                    break;
                  }
              if (hdh_q == NULL)
-               hdh_pp = &hdh_p->hdh_next;
+               hdh_pp = &hdh_p->next;
            }
          *hdh_pp = hh_dir->dyn_relocs;
        }
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct elf_metag_dyn_reloc_entry *p;
+  struct elf_dyn_relocs *p;
 
-  for (p = metag_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->hdh_next)
+  for (p = metag_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
       asection *s = p->sec->output_section;
 
                                 struct elf_link_hash_entry *eh)
 {
   struct elf_metag_link_hash_table *htab;
-  struct elf_metag_link_hash_entry *hh;
-  struct elf_metag_dyn_reloc_entry *hdh_p;
   asection *s, *srel;
 
   /* If this is a function, put it in the procedure linkage table.  We
       return TRUE;
     }
 
-  hh = (struct elf_metag_link_hash_entry *) eh;
-  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
-    {
-      s = hdh_p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in read-only sections, then
+  /* 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 (hdh_p == NULL)
+  if (!readonly_dynrelocs (eh))
     {
       eh->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf_metag_link_hash_table *htab;
   struct elf_metag_link_hash_entry *hh;
-  struct elf_metag_dyn_reloc_entry *hdh_p;
+  struct elf_dyn_relocs *hdh_p;
 
   if (eh->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (SYMBOL_CALLS_LOCAL (info, eh))
        {
-         struct elf_metag_dyn_reloc_entry **hdh_pp;
+         struct elf_dyn_relocs **hdh_pp;
 
          for (hdh_pp = &hh->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
            {
-             hdh_p->count -= hdh_p->relative_count;
-             hdh_p->relative_count = 0;
+             hdh_p->count -= hdh_p->pc_count;
+             hdh_p->pc_count = 0;
              if (hdh_p->count == 0)
-               *hdh_pp = hdh_p->hdh_next;
+               *hdh_pp = hdh_p->next;
              else
-               hdh_pp = &hdh_p->hdh_next;
+               hdh_pp = &hdh_p->next;
            }
        }
 
     }
 
   /* Finally, allocate space.  */
-  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
+  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->next)
     {
       asection *sreloc = elf_section_data (hdh_p->sec)->sreloc;
       sreloc->size += hdh_p->count * sizeof (Elf32_External_Rela);
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct elf_metag_dyn_reloc_entry *hdh_p;
+         struct elf_dyn_relocs *hdh_p;
 
-         for (hdh_p = ((struct elf_metag_dyn_reloc_entry *)
+         for (hdh_p = ((struct elf_dyn_relocs *)
                        elf_section_data (s)->local_dynrel);
               hdh_p != NULL;
-              hdh_p = hdh_p->hdh_next)
+              hdh_p = hdh_p->next)
            {
              if (!bfd_is_abs_section (hdh_p->sec)
                  && bfd_is_abs_section (hdh_p->sec->output_section))
 
   return _bfd_elf_is_local_label_name (abfd, name);
 }
 
-/* The microblaze linker (like many others) needs to keep track of
-   the number of relocs that it decides to copy as dynamic relocs in
-   check_relocs for each symbol. This is so that it can later discard
-   them if they are found to be unnecessary.  We store the information
-   in a field extending the regular ELF linker hash table.  */
-
-struct elf32_mb_dyn_relocs
-{
-  struct elf32_mb_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* ELF linker hash entry.  */
 
 struct elf32_mb_link_hash_entry
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf32_mb_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   /* TLS Reference Types for the symbol; Updated by check_relocs */
 #define TLS_GD     1  /* GD reloc. */
                     && (h->root.type == bfd_link_hash_defweak
                         || !h->def_regular)))
               {
-                struct elf32_mb_dyn_relocs *p;
-                struct elf32_mb_dyn_relocs **head;
+                struct elf_dyn_relocs *p;
+                struct elf_dyn_relocs **head;
 
                 /* When creating a shared object, we must copy these
                    relocs into the output file.  We create a reloc
                      return FALSE;
 
                    vpp = &elf_section_data (s)->local_dynrel;
-                   head = (struct elf32_mb_dyn_relocs **) vpp;
+                   head = (struct elf_dyn_relocs **) vpp;
                  }
 
                p = *head;
                if (p == NULL || p->sec != sec)
                  {
                    bfd_size_type amt = sizeof *p;
-                   p = ((struct elf32_mb_dyn_relocs *)
+                   p = ((struct elf_dyn_relocs *)
                         bfd_alloc (htab->elf.dynobj, amt));
                    if (p == NULL)
                      return FALSE;
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct elf32_mb_dyn_relocs **pp;
-         struct elf32_mb_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          if (ind->root.type == bfd_link_hash_indirect)
            abort ();
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct elf32_mb_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
   _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)
 {
   struct elf32_mb_link_hash_table *htab;
-  struct elf32_mb_link_hash_entry * eh;
-  struct elf32_mb_dyn_relocs *p;
   asection *s, *srel;
   unsigned int power_of_two;
 
       return TRUE;
     }
 
-  eh = (struct elf32_mb_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in read-only sections, then
+  /* 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 (p == NULL)
+  if (!readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf32_mb_link_hash_table *htab;
   struct elf32_mb_link_hash_entry *eh;
-  struct elf32_mb_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
          && (h->forced_local
              || info->symbolic))
        {
-         struct elf32_mb_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct elf32_mb_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
-         for (p = ((struct elf32_mb_dyn_relocs *)
+         for (p = ((struct elf_dyn_relocs *)
                    elf_section_data (s)->local_dynrel);
               p != NULL;
               p = p->next)
 
   bfd_size_type count;
 };
 
-/* The sh linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_nds32_dyn_relocs
-{
-  struct elf_nds32_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* Nds32 ELF linker hash entry.  */
 
 struct elf_nds32_link_hash_entry
   struct elf_link_hash_entry root;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_nds32_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   /* For checking relocation type.  */
 #define GOT_UNKNOWN     0
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct elf_nds32_dyn_relocs **pp;
-         struct elf_nds32_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          if (ind->root.type == bfd_link_hash_indirect)
            abort ();
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
            {
-             struct elf_nds32_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct elf_nds32_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   for (p = elf32_nds32_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
                                 struct elf_link_hash_entry *h)
 {
   struct elf_nds32_link_hash_table *htab;
-  struct elf_nds32_link_hash_entry *eh;
-  struct elf_nds32_dyn_relocs *p;
   bfd *dynobj;
   asection *s;
   unsigned int power_of_two;
     return TRUE;
 
   /* If -z nocopyreloc was given, we won't generate them either.  */
-  if (info->nocopyreloc)
+  if (0 && info->nocopyreloc)
     {
       h->non_got_ref = 0;
       return TRUE;
     }
 
-  eh = (struct elf_nds32_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in sections which needs the
-     copy reloc, then we'll be keeping the dynamic relocs and avoiding
-     the copy reloc.  */
-  if (p == NULL)
+  /* 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 (0 && !readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf_nds32_link_hash_table *htab;
   struct elf_nds32_link_hash_entry *eh;
-  struct elf_nds32_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (h->def_regular && (h->forced_local || info->symbolic))
        {
-         struct elf_nds32_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct elf_nds32_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
-         for (p = ((struct elf_nds32_dyn_relocs *)
+         for (p = ((struct elf_dyn_relocs *)
                    elf_section_data (s)->local_dynrel);
               p != NULL; p = p->next)
            {
                  && (h->root.type == bfd_link_hash_defweak
                      || !h->def_regular)))
            {
-             struct elf_nds32_dyn_relocs *p;
-             struct elf_nds32_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              if (dynobj == NULL)
                htab->root.dynobj = dynobj = abfd;
                    return FALSE;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct elf_nds32_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
              if (p == NULL || p->sec != sec)
                {
                  bfd_size_type amt = sizeof (*p);
-                 p = (struct elf_nds32_dyn_relocs *) bfd_alloc (dynobj, amt);
+                 p = (struct elf_dyn_relocs *) bfd_alloc (dynobj, amt);
                  if (p == NULL)
                    return FALSE;
                  p->next = *head;
 
    bfd_hash_lookup ((table), (string), (create), (copy)))
 
 
-/* The Nios II linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf32_nios2_dyn_relocs
-{
-  struct elf32_nios2_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* Nios II ELF linker hash entry.  */
 
 struct elf32_nios2_link_hash_entry
   struct elf32_nios2_stub_hash_entry *hsh_cache;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf32_nios2_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
 #define GOT_UNKNOWN    0
 #define GOT_NORMAL     1
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct elf32_nios2_dyn_relocs **pp;
-         struct elf32_nios2_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct elf32_nios2_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  || (h != NULL && ! h->needs_plt
                      && (! SYMBOLIC_BIND (info, h) || ! h->def_regular))))
            {
-             struct elf32_nios2_dyn_relocs *p;
-             struct elf32_nios2_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              /* When creating a shared object, we must copy these
                 reloc types into the output file.  We create a reloc
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct elf32_nios2_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
              if (p == NULL || p->sec != sec)
                {
                  bfd_size_type amt = sizeof *p;
-                 p = ((struct elf32_nios2_dyn_relocs *)
+                 p = ((struct elf_dyn_relocs *)
                       bfd_alloc (htab->root.dynobj, amt));
                  if (p == NULL)
                    return FALSE;
   struct bfd_link_info *info;
   struct elf32_nios2_link_hash_table *htab;
   struct elf32_nios2_link_hash_entry *eh;
-  struct elf32_nios2_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
   int use_plt;
 
   if (h->root.type == bfd_link_hash_indirect)
       if (h->def_regular
          && (h->forced_local || SYMBOLIC_BIND (info, h)))
        {
-         struct elf32_nios2_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct elf32_nios2_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
          for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
            {
 
   { BFD_RELOC_OR1K_TLS_LE_LO16, R_OR1K_TLS_LE_LO16 },
 };
 
-/* The linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_or1k_dyn_relocs
-{
-  struct elf_or1k_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 #define TLS_UNKNOWN    0
 #define TLS_NONE       1
 #define TLS_GD         2
   struct elf_link_hash_entry root;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_or1k_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   /* Track type of TLS access.  */
   unsigned char tls_type;
                     && (h->root.type == bfd_link_hash_defweak
                         || !h->def_regular)))
               {
-                struct elf_or1k_dyn_relocs *p;
-                struct elf_or1k_dyn_relocs **head;
+                struct elf_dyn_relocs *p;
+                struct elf_dyn_relocs **head;
 
                 /* When creating a shared object, we must copy these
                    relocs into the output file.  We create a reloc
                       return FALSE;
 
                     vpp = &elf_section_data (s)->local_dynrel;
-                    head = (struct elf_or1k_dyn_relocs **) vpp;
+                    head = (struct elf_dyn_relocs **) vpp;
                   }
 
                 p = *head;
                 if (p == NULL || p->sec != sec)
                   {
                     bfd_size_type amt = sizeof *p;
-                    p = ((struct elf_or1k_dyn_relocs *)
+                    p = ((struct elf_dyn_relocs *)
                          bfd_alloc (htab->root.dynobj, amt));
                     if (p == NULL)
                       return FALSE;
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct elf_or1k_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
   struct elf_or1k_link_hash_entry *eh = (struct elf_or1k_link_hash_entry *) h;
 
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
                                 struct elf_link_hash_entry *h)
 {
   struct elf_or1k_link_hash_table *htab;
-  struct elf_or1k_link_hash_entry *eh;
-  struct elf_or1k_dyn_relocs *p;
   bfd *dynobj;
   asection *s, *srel;
 
       return TRUE;
     }
 
-  eh = (struct elf_or1k_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0)
-        break;
-    }
-
-  /* If we didn't find any dynamic relocs in sections which needs the
-     copy reloc, then we'll be keeping the dynamic relocs and avoiding
-     the copy reloc.  */
-  if (p == NULL)
+  /* 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))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf_or1k_link_hash_table *htab;
   struct elf_or1k_link_hash_entry *eh;
-  struct elf_or1k_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
         {
-          struct elf_or1k_dyn_relocs **pp;
+          struct elf_dyn_relocs **pp;
 
           for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
             {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
         {
-          struct elf_or1k_dyn_relocs *p;
+          struct elf_dyn_relocs *p;
 
-          for (p = ((struct elf_or1k_dyn_relocs *)
+          for (p = ((struct elf_dyn_relocs *)
                     elf_section_data (s)->local_dynrel);
                p != NULL;
                p = p->next)
     {
       if (edir->dyn_relocs != NULL)
         {
-          struct elf_or1k_dyn_relocs **pp;
-          struct elf_or1k_dyn_relocs *p;
+          struct elf_dyn_relocs **pp;
+          struct elf_dyn_relocs *p;
 
           /* Add reloc counts against the indirect sym to the direct sym
              list.  Merge any entries against the same section.  */
           for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
             {
-              struct elf_or1k_dyn_relocs *q;
+              struct elf_dyn_relocs *q;
 
               for (q = edir->dyn_relocs; q != NULL; q = q->next)
                 if (q->sec == p->sec)
 
       return TRUE;
     }
 
-  if (ELIMINATE_COPY_RELOCS)
+  /* 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 (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h))
     {
-      struct elf_s390_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
-      eh = (struct elf_s390_link_hash_entry *) h;
-      for (p = eh->dyn_relocs; p != NULL; p = p->next)
-       {
-         s = p->sec->output_section;
-         if (s != NULL && (s->flags & SEC_READONLY) != 0)
-           break;
-       }
-
-      /* If we didn't find any dynamic relocs in read-only sections, then
-        we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-      if (p == NULL)
-       {
-         h->non_got_ref = 0;
-         return TRUE;
-       }
+      h->non_got_ref = 0;
+      return TRUE;
     }
 
   /* We must allocate the symbol in our .dynbss section, which will
 
          + (plt_index * info->symbol_entry_size));
 }
 
-/* The sh linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_sh_dyn_relocs
-{
-  struct elf_sh_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 union gotref
 {
   bfd_signed_vma refcount;
 #endif
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_sh_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   bfd_signed_vma gotplt_refcount;
 
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct elf_sh_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   for (p = sh_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
                              struct elf_link_hash_entry *h)
 {
   struct elf_sh_link_hash_table *htab;
-  struct elf_sh_link_hash_entry *eh;
-  struct elf_sh_dyn_relocs *p;
   asection *s;
 
   htab = sh_elf_hash_table (info);
     return TRUE;
 
   /* If -z nocopyreloc was given, we won't generate them either.  */
-  if (info->nocopyreloc)
+  if (0 && info->nocopyreloc)
     {
       h->non_got_ref = 0;
       return TRUE;
     }
 
-  eh = (struct elf_sh_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in sections which needs the
-     copy reloc, then we'll be keeping the dynamic relocs and avoiding
-     the copy reloc.  */
-  if (p == NULL)
+  /* 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 (0 && !readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct elf_sh_link_hash_table *htab;
   struct elf_sh_link_hash_entry *eh;
-  struct elf_sh_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
        {
-         struct elf_sh_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       if (htab->vxworks_p)
        {
-         struct elf_sh_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct elf_sh_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
-         for (p = ((struct elf_sh_dyn_relocs *)
+         for (p = ((struct elf_dyn_relocs *)
                    elf_section_data (s)->local_dynrel);
               p != NULL;
               p = p->next)
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct elf_sh_dyn_relocs **pp;
-         struct elf_sh_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct elf_sh_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  && (h->root.type == bfd_link_hash_defweak
                      || !h->def_regular)))
            {
-             struct elf_sh_dyn_relocs *p;
-             struct elf_sh_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              if (htab->root.dynobj == NULL)
                htab->root.dynobj = abfd;
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct elf_sh_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
 
 
 
 
-/* The TILEPro linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct tilepro_elf_dyn_relocs
-{
-  struct tilepro_elf_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* TILEPRO ELF linker hash entry.  */
 
 struct tilepro_elf_link_hash_entry
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct tilepro_elf_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
 #define GOT_UNKNOWN     0
 #define GOT_NORMAL      1
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct tilepro_elf_dyn_relocs **pp;
-         struct tilepro_elf_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct tilepro_elf_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  && (h->root.type == bfd_link_hash_defweak
                      || !h->def_regular)))
            {
-             struct tilepro_elf_dyn_relocs *p;
-             struct tilepro_elf_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              /* When creating a shared object, we must copy these
                 relocs into the output file.  We create a reloc
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct tilepro_elf_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
              if (p == NULL || p->sec != sec)
                {
                  bfd_size_type amt = sizeof *p;
-                 p = ((struct tilepro_elf_dyn_relocs *)
+                 p = ((struct elf_dyn_relocs *)
                       bfd_alloc (htab->elf.dynobj, amt));
                  if (p == NULL)
                    return FALSE;
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct tilepro_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   for (p = tilepro_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
                                   struct elf_link_hash_entry *h)
 {
   struct tilepro_elf_link_hash_table *htab;
-  struct tilepro_elf_link_hash_entry * eh;
-  struct tilepro_elf_dyn_relocs *p;
   asection *s, *srel;
 
   htab = tilepro_elf_hash_table (info);
       return TRUE;
     }
 
-  eh = (struct tilepro_elf_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in read-only sections, then
+  /* 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 (p == NULL)
+  if (!readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct tilepro_elf_link_hash_table *htab;
   struct tilepro_elf_link_hash_entry *eh;
-  struct tilepro_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
        {
-         struct tilepro_elf_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct tilepro_elf_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
          for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
            {
 
       return TRUE;
     }
 
-  if (ELIMINATE_COPY_RELOCS)
+  /* 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 (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h))
     {
-      struct elf_s390_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
-      eh = (struct elf_s390_link_hash_entry *) h;
-      for (p = eh->dyn_relocs; p != NULL; p = p->next)
-       {
-         s = p->sec->output_section;
-         if (s != NULL && (s->flags & SEC_READONLY) != 0)
-           break;
-       }
-
-      /* If we didn't find any dynamic relocs in read-only sections, then
-        we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-      if (p == NULL)
-       {
-         h->non_got_ref = 0;
-         return TRUE;
-       }
+      h->non_got_ref = 0;
+      return TRUE;
     }
 
   /* We must allocate the symbol in our .dynbss section, which will
 
 #define ELF_MAXPAGESIZE                        0x1000
 #define ELF_COMMONPAGESIZE             0x1000
 
-/* The RISC-V linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct riscv_elf_dyn_relocs
-{
-  struct riscv_elf_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* RISC-V ELF linker hash entry.  */
 
 struct riscv_elf_link_hash_entry
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct riscv_elf_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
 #define GOT_UNKNOWN     0
 #define GOT_NORMAL      1
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct riscv_elf_dyn_relocs **pp;
-         struct riscv_elf_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct riscv_elf_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  && (h->root.type == bfd_link_hash_defweak
                      || !h->def_regular)))
            {
-             struct riscv_elf_dyn_relocs *p;
-             struct riscv_elf_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              /* When creating a shared object, we must copy these
                 relocs into the output file.  We create a reloc
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct riscv_elf_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
              if (p == NULL || p->sec != sec)
                {
                  bfd_size_type amt = sizeof *p;
-                 p = ((struct riscv_elf_dyn_relocs *)
+                 p = ((struct elf_dyn_relocs *)
                       bfd_alloc (htab->elf.dynobj, amt));
                  if (p == NULL)
                    return FALSE;
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct riscv_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   for (p = riscv_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
 {
   struct riscv_elf_link_hash_table *htab;
   struct riscv_elf_link_hash_entry * eh;
-  struct riscv_elf_dyn_relocs *p;
   bfd *dynobj;
   asection *s, *srel;
 
       return TRUE;
     }
 
-  eh = (struct riscv_elf_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in read-only sections, then
+  /* 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 (p == NULL)
+  if (!readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rel.bss section we are going to use.  */
+  eh = (struct riscv_elf_link_hash_entry *) h;
   if (eh->tls_type & ~GOT_NORMAL)
     {
       s = htab->sdyntdata;
   struct bfd_link_info *info;
   struct riscv_elf_link_hash_table *htab;
   struct riscv_elf_link_hash_entry *eh;
-  struct riscv_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
        {
-         struct riscv_elf_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct riscv_elf_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
          for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
            {
 
 
 #define SPARC_INSN_BYTES       4
 
-/* The SPARC linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct _bfd_sparc_elf_dyn_relocs
-{
-  struct _bfd_sparc_elf_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* Is an undefined weak symbol resolved to 0 ?
    Reference to an undefined weak symbol is resolved to 0 when
    building an executable if it isn't dynamic and
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct _bfd_sparc_elf_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
 #define GOT_UNKNOWN     0
 #define GOT_NORMAL      1
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct _bfd_sparc_elf_dyn_relocs **pp;
-         struct _bfd_sparc_elf_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct _bfd_sparc_elf_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  && h != NULL
                  && h->type == STT_GNU_IFUNC))
            {
-             struct _bfd_sparc_elf_dyn_relocs *p;
-             struct _bfd_sparc_elf_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              /* When creating a shared object, we must copy these
                 relocs into the output file.  We create a reloc
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct _bfd_sparc_elf_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
              if (p == NULL || p->sec != sec)
                {
                  bfd_size_type amt = sizeof *p;
-                 p = ((struct _bfd_sparc_elf_dyn_relocs *)
+                 p = ((struct elf_dyn_relocs *)
                       bfd_alloc (htab->elf.dynobj, amt));
                  if (p == NULL)
                    return FALSE;
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct _bfd_sparc_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   for (p = _bfd_sparc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
                                     struct elf_link_hash_entry *h)
 {
   struct _bfd_sparc_elf_link_hash_table *htab;
-  struct _bfd_sparc_elf_link_hash_entry * eh;
-  struct _bfd_sparc_elf_dyn_relocs *p;
   asection *s, *srel;
 
   htab = _bfd_sparc_elf_hash_table (info);
       return TRUE;
     }
 
-  eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in read-only sections, then
+  /* 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 (p == NULL)
+  if (!readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct _bfd_sparc_elf_link_hash_table *htab;
   struct _bfd_sparc_elf_link_hash_entry *eh;
-  struct _bfd_sparc_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
   bfd_boolean resolved_to_zero;
 
   if (h->root.type == bfd_link_hash_indirect)
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
        {
-         struct _bfd_sparc_elf_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       if (htab->is_vxworks)
        {
-         struct _bfd_sparc_elf_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
                 {
                   /* Keep dynamic non-GOT/non-PLT relocation so that we
                      can branch to 0 without PLT.  */
-                  struct _bfd_sparc_elf_dyn_relocs **pp;
+                  struct elf_dyn_relocs **pp;
 
                   for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
                     if (p->pc_count == 0)
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct _bfd_sparc_elf_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
          for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
            {
 
 
 
 
-/* The TILE-Gx linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct tilegx_elf_dyn_relocs
-{
-  struct tilegx_elf_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
-
 /* TILEGX ELF linker hash entry.  */
 
 struct tilegx_elf_link_hash_entry
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct tilegx_elf_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
 #define GOT_UNKNOWN     0
 #define GOT_NORMAL      1
     {
       if (edir->dyn_relocs != NULL)
        {
-         struct tilegx_elf_dyn_relocs **pp;
-         struct tilegx_elf_dyn_relocs *p;
+         struct elf_dyn_relocs **pp;
+         struct elf_dyn_relocs *p;
 
          /* Add reloc counts against the indirect sym to the direct sym
             list.  Merge any entries against the same section.  */
          for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
            {
-             struct tilegx_elf_dyn_relocs *q;
+             struct elf_dyn_relocs *q;
 
              for (q = edir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  && (h->root.type == bfd_link_hash_defweak
                      || !h->def_regular)))
            {
-             struct tilegx_elf_dyn_relocs *p;
-             struct tilegx_elf_dyn_relocs **head;
+             struct elf_dyn_relocs *p;
+             struct elf_dyn_relocs **head;
 
              /* When creating a shared object, we must copy these
                 relocs into the output file.  We create a reloc
                    s = sec;
 
                  vpp = &elf_section_data (s)->local_dynrel;
-                 head = (struct tilegx_elf_dyn_relocs **) vpp;
+                 head = (struct elf_dyn_relocs **) vpp;
                }
 
              p = *head;
              if (p == NULL || p->sec != sec)
                {
                  bfd_size_type amt = sizeof *p;
-                 p = ((struct tilegx_elf_dyn_relocs *)
+                 p = ((struct elf_dyn_relocs *)
                       bfd_alloc (htab->elf.dynobj, amt));
                  if (p == NULL)
                    return FALSE;
 static asection *
 readonly_dynrelocs (struct elf_link_hash_entry *h)
 {
-  struct tilegx_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   for (p = tilegx_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
     {
                                  struct elf_link_hash_entry *h)
 {
   struct tilegx_elf_link_hash_table *htab;
-  struct tilegx_elf_link_hash_entry * eh;
-  struct tilegx_elf_dyn_relocs *p;
   bfd *dynobj;
   asection *s, *srel;
 
       return TRUE;
     }
 
-  eh = (struct tilegx_elf_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
-    {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       break;
-    }
-
-  /* If we didn't find any dynamic relocs in read-only sections, then
+  /* 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 (p == NULL)
+  if (!readonly_dynrelocs (h))
     {
       h->non_got_ref = 0;
       return TRUE;
   struct bfd_link_info *info;
   struct tilegx_elf_link_hash_table *htab;
   struct tilegx_elf_link_hash_entry *eh;
-  struct tilegx_elf_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
        {
-         struct tilegx_elf_dyn_relocs **pp;
+         struct elf_dyn_relocs **pp;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
            {
 
       for (s = ibfd->sections; s != NULL; s = s->next)
        {
-         struct tilegx_elf_dyn_relocs *p;
+         struct elf_dyn_relocs *p;
 
          for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
            {