Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-metag.c
index 39d3fffcb66b76d3cafebb03ee9cdbabc075bb2a..40a2bafa2cf93bde96fd68cb064b7dd43943817d 100644 (file)
@@ -1,5 +1,5 @@
 /* Meta support for 32-bit ELF
-   Copyright (C) 2013-2016 Free Software Foundation, Inc.
+   Copyright (C) 2013-2017 Free Software Foundation, Inc.
    Contributed by Imagination Technologies Ltd.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -842,10 +842,6 @@ struct elf_metag_link_hash_table
   asection **input_list;
   Elf_Internal_Sym **all_local_syms;
 
-  /* Short-cuts to get to dynamic linker sections.  */
-  asection *sdynbss;
-  asection *srelbss;
-
   /* Small local sym cache.  */
   struct sym_cache sym_cache;
 
@@ -2069,9 +2065,6 @@ elf_metag_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   htab->etab.hgot = eh;
 
-  htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
-  htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
-
   return TRUE;
 }
 
@@ -2477,7 +2470,7 @@ elf_metag_adjust_dynamic_symbol (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;
-  asection *s;
+  asection *s, *srel;
 
   /* If this is a function, put it in the procedure linkage table.  We
      will fill in the contents of the procedure linkage table later,
@@ -2571,14 +2564,22 @@ elf_metag_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* We must generate a COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  */
+  if ((eh->root.u.def.section->flags & SEC_READONLY) != 0)
+    {
+      s = htab->etab.sdynrelro;
+      srel = htab->etab.sreldynrelro;
+    }
+  else
+    {
+      s = htab->etab.sdynbss;
+      srel = htab->etab.srelbss;
+    }
   if ((eh->root.u.def.section->flags & SEC_ALLOC) != 0 && eh->size != 0)
     {
-      htab->srelbss->size += sizeof (Elf32_External_Rela);
+      srel->size += sizeof (Elf32_External_Rela);
       eh->needs_copy = 1;
     }
 
-  s = htab->sdynbss;
-
   return _bfd_elf_adjust_dynamic_copy (info, eh, s);
 }
 
@@ -2940,7 +2941,8 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       if (s == htab->etab.splt
          || s == htab->etab.sgot
          || s == htab->etab.sgotplt
-         || s == htab->sdynbss)
+         || s == htab->etab.sdynbss
+         || s == htab->etab.sdynrelro)
        {
          /* Strip this section if we don't need it; see the
             comment below.  */
@@ -3222,13 +3224,15 @@ elf_metag_finish_dynamic_symbol (bfd *output_bfd,
                 || eh->root.type == bfd_link_hash_defweak)))
        abort ();
 
-      s = htab->srelbss;
-
       rel.r_offset = (eh->root.u.def.value
                      + eh->root.u.def.section->output_offset
                      + eh->root.u.def.section->output_section->vma);
       rel.r_addend = 0;
       rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_COPY);
+      if ((eh->root.u.def.section->flags & SEC_READONLY) != 0)
+       s = htab->etab.sreldynrelro;
+      else
+       s = htab->etab.srelbss;
       loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
@@ -4293,6 +4297,7 @@ elf_metag_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_want_plt_sym               0
 #define elf_backend_plt_readonly               1
 #define elf_backend_dtrel_excludes_plt         1
+#define elf_backend_want_dynrelro              1
 
 #define bfd_elf32_bfd_reloc_type_lookup        metag_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup        metag_reloc_name_lookup
This page took 0.025584 seconds and 4 git commands to generate.