gas/hash.c: add new functions
[binutils-gdb.git] / bfd / elf32-nios2.c
index 453b7cf5a3de86d3ab01eae39f5fd1e9baa3a37e..153bfadc619ac14ce95d5d24d98034ce30ac321a 100644 (file)
@@ -1808,9 +1808,6 @@ struct elf32_nios2_link_hash_table
       bfd_vma offset;
     } tls_ldm_got;
 
-    /* Small local sym cache.  */
-    struct sym_cache sym_cache;
-
     bfd_vma res_n_size;
   };
 
@@ -4689,15 +4686,6 @@ nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
   if (bfd_link_relocatable (info))
     return TRUE;
 
-  /* Don't do anything special with non-loaded, non-alloced sections.
-     In particular, any relocs in such sections should not affect GOT
-     and PLT reference counting (ie. we don't allow them to create GOT
-     or PLT entries), there's no possibility or desire to optimize TLS
-     relocs, and there's not much point in propagating relocs to shared
-     libs that the dynamic linker won't relocate.  */
-  if ((sec->flags & SEC_ALLOC) == 0)
-    return TRUE;
-
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   sym_hashes_end = (sym_hashes
@@ -4911,7 +4899,7 @@ nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
                  void *vpp;
                  Elf_Internal_Sym *isym;
 
-                 isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+                 isym = bfd_sym_from_r_symndx (&htab->root.sym_cache,
                                                abfd, r_symndx);
                  if (isym == NULL)
                    return FALSE;
@@ -5761,8 +5749,6 @@ nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
                {
                  srel = elf_section_data (p->sec)->sreloc;
                  srel->size += p->count * sizeof (Elf32_External_Rela);
-                 if ((p->sec->output_section->flags & SEC_READONLY) != 0)
-                   info->flags |= DF_TEXTREL;
                }
            }
        }
@@ -5888,45 +5874,7 @@ nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab->res_n_size)
     elf_link_hash_traverse (& htab->root, adjust_dynrelocs, info);
 
-  if (htab->root.dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-        values later, in elf_nios2_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_pic (info) && !add_dynamic_entry (DT_DEBUG, 0))
-       return FALSE;
-
-      if (htab->root.sgotplt->size != 0
-         && !add_dynamic_entry (DT_PLTGOT, 0))
-       return FALSE;
-
-      if (htab->root.splt->size != 0
-         && (!add_dynamic_entry (DT_PLTRELSZ, 0)
-             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
-             || !add_dynamic_entry (DT_JMPREL, 0)))
-       return FALSE;
-
-      if (relocs
-         && (!add_dynamic_entry (DT_RELA, 0)
-             || !add_dynamic_entry (DT_RELASZ, 0)
-             || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))))
-       return FALSE;
-
-      if (!bfd_link_pic (info) && !add_dynamic_entry (DT_NIOS2_GP, 0))
-       return FALSE;
-
-      if ((info->flags & DF_TEXTREL) != 0
-         && !add_dynamic_entry (DT_TEXTREL, 0))
-       return FALSE;
-    }
-#undef add_dynamic_entry
-
-  return TRUE;
+  return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
 }
 
 /* Free the derived linker hash table.  */
@@ -6024,7 +5972,7 @@ nios2_elf_add_symbol_hook (bfd *abfd,
       htab = elf32_nios2_hash_table (info);
       if (htab->sbss == NULL)
        {
-         flagword flags = SEC_IS_COMMON | SEC_LINKER_CREATED;
+         flagword flags = SEC_IS_COMMON | SEC_SMALL_DATA | SEC_LINKER_CREATED;
 
          if (htab->root.dynobj == NULL)
            htab->root.dynobj = abfd;