Don't make dynamic .data.rel.ro SEC_READONLY
[deliverable/binutils-gdb.git] / bfd / elf32-cris.c
index 7799cf4f041d690d7a7292c4bf811ea56bc98515..97b8cc3eb85c4c983d16fbaef68478c6deba2a97 100644 (file)
@@ -1,5 +1,5 @@
 /* CRIS-specific support for 32-bit ELF.
-   Copyright (C) 2000-2016 Free Software Foundation, Inc.
+   Copyright (C) 2000-2017 Free Software Foundation, Inc.
    Contributed by Axis Communications AB.
    Written by Hans-Peter Nilsson, based on elf32-fr30.c
    PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c.
@@ -463,6 +463,7 @@ cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
   r_type = ELF32_R_TYPE (dst->r_info);
   if (r_type >= R_CRIS_max)
     {
+      /* xgettext:c-format */
       _bfd_error_handler (_("%B: invalid CRIS reloc number: %d"), abfd, r_type);
       r_type = 0;
     }
@@ -989,7 +990,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
   local_got_offsets = elf_local_got_offsets (input_bfd);
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -1002,8 +1003,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   if (dynobj != NULL)
     {
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgot = bfd_get_linker_section (dynobj, ".got");
+      splt = htab->root.splt;
+      sgot = htab->root.sgot;
     }
 
   for (rel = relocs; rel < relend; rel ++)
@@ -1110,6 +1111,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                           != (bfd_vma) -1))
                {
                  _bfd_error_handler
+                   /* xgettext:c-format */
                    (_("%B, section %A: unresolvable relocation %s against symbol `%s'"),
                     input_bfd,
                     input_section,
@@ -1140,8 +1142,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          if (h != NULL
              && ((struct elf_cris_link_hash_entry *) h)->gotplt_offset != 0)
            {
-             asection *sgotplt
-               = bfd_get_linker_section (dynobj, ".got.plt");
+             asection *sgotplt = htab->root.sgotplt;
              bfd_vma got_offset;
 
              BFD_ASSERT (h->dynindx != -1);
@@ -1170,10 +1171,12 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                           || (!h->def_dynamic
                               && h->root.type == bfd_link_hash_undefweak)))))
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
                ((h->got.offset == (bfd_vma) -1)
+                /* xgettext:c-format */
                 ? _("%B, section %A: No PLT nor GOT for relocation %s"
                     " against symbol `%s'")
+                /* xgettext:c-format */
                 : _("%B, section %A: No PLT for relocation %s"
                     " against symbol `%s'"),
                 input_bfd,
@@ -1271,9 +1274,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                        Elf_Internal_Rela outrel;
                        bfd_byte *loc;
 
-                       if (srelgot == NULL)
-                         srelgot
-                           = bfd_get_linker_section (dynobj, ".rela.got");
+                       srelgot = htab->root.srelgot;
                        BFD_ASSERT (srelgot != NULL);
 
                        outrel.r_offset = (sgot->output_section->vma
@@ -1298,7 +1299,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                   symbols.  Make this an error; the compiler isn't
                   allowed to pass us these kinds of things.  */
                if (h == NULL)
-                 (*_bfd_error_handler)
+                 _bfd_error_handler
+                   /* xgettext:c-format */
                    (_("%B, section %A: relocation %s with non-zero addend %d"
                       " against local symbol"),
                     input_bfd,
@@ -1306,7 +1308,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                     cris_elf_howto_table[r_type].name,
                     rel->r_addend);
                else
-                 (*_bfd_error_handler)
+                 _bfd_error_handler
+                   /* xgettext:c-format */
                    (_("%B, section %A: relocation %s with non-zero addend %d"
                       " against symbol `%s'"),
                     input_bfd,
@@ -1332,7 +1335,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                       || (!h->def_dynamic
                           && h->root.type == bfd_link_hash_undefweak))))
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A: relocation %s is"
                   " not allowed for global symbol: `%s'"),
                 input_bfd,
@@ -1348,7 +1352,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
             it's noticed if it happens elsewhere.  */
          if (sgot == NULL)
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A: relocation %s with no GOT created"),
                 input_bfd,
                 input_section,
@@ -1561,12 +1566,14 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  || (!h->def_regular
                      && h->root.type != bfd_link_hash_undefined)))
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
                ((h->root.type == bfd_link_hash_undefined)
                 /* We shouldn't get here for GCC-emitted code.  */
+                /* xgettext:c-format */
                 ? _("%B, section %A: relocation %s has an undefined"
                     " reference to `%s', perhaps a declaration mixup?")
-                : ("%B, section %A: relocation %s is"
+                /* xgettext:c-format */
+                : _("%B, section %A: relocation %s is"
                     " not allowed for `%s', a global symbol with default"
                     " visibility, perhaps a declaration mixup?"),
                 input_bfd,
@@ -1589,7 +1596,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          if (htab->dtpmod_refcount > 0
              && (input_section->flags & SEC_ALLOC) != 0)
            {
-             asection *sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+             asection *sgotplt = htab->root.sgotplt;
              BFD_ASSERT (sgotplt != NULL);
 
              if (bfd_link_pic (info))
@@ -1597,8 +1604,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  Elf_Internal_Rela outrel;
                  bfd_byte *loc;
 
-                 if (srelgot == NULL)
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+                 srelgot = htab->root.srelgot;
                  BFD_ASSERT (srelgot != NULL);
                  loc = srelgot->contents;
                  loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
@@ -1649,7 +1655,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                 symbol *plus offset*.  The GOT holds relocations for
                 symbols.  Make this an error; the compiler isn't allowed
                 to pass us these kinds of things.  */
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A: relocation %s with non-zero addend %d"
                   " against symbol `%s'"),
                 input_bfd,
@@ -1741,8 +1748,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  bfd_put_32 (output_bfd, 0, sgot->contents + off);
                  bfd_put_32 (output_bfd, 0, sgot->contents + off + 4);
 
-                 if (srelgot == NULL)
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+                 srelgot = htab->root.srelgot;
                  BFD_ASSERT (srelgot != NULL);
 
                  if (h != NULL && h->dynindx != -1)
@@ -1802,7 +1808,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                 relocations for symbols.  Make this an error; the
                 compiler isn't allowed to pass us these kinds of
                 things.  */
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A: relocation %s with non-zero addend %d"
                   " against symbol `%s'"),
                 input_bfd,
@@ -1873,8 +1880,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  else
                    local_got_offsets[r_symndx] |= 1;
 
-                 if (srelgot == NULL)
-                   srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+                 srelgot = htab->root.srelgot;
                  BFD_ASSERT (srelgot != NULL);
 
                  if (h != NULL && h->dynindx != -1)
@@ -1936,7 +1942,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                 been emitted.  */
              && h->root.type != bfd_link_hash_undefined)
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A: relocation %s is"
                   " not allowed for symbol: `%s'"
                   " which is defined outside the program,"
@@ -1973,7 +1980,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          switch (r)
            {
            case bfd_reloc_overflow:
-             r = info->callbacks->reloc_overflow
+             (*info->callbacks->reloc_overflow)
                (info, (h ? &h->root : NULL), symname, howto->name,
                 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
              if (additional_relocation_error_msg_count > 0)
@@ -1989,14 +1996,14 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                         only.  */
                    case R_CRIS_16_GOT_TPREL:
                    case R_CRIS_16_GOT_GD:
-                     (*_bfd_error_handler)
+                     _bfd_error_handler
                        (_("(too many global variables for -fpic:"
                           " recompile with -fPIC)"));
                      break;
 
                    case R_CRIS_16_TPREL:
                    case R_CRIS_16_DTPREL:
-                     (*_bfd_error_handler)
+                     _bfd_error_handler
                        (_("(thread-local data too big for -fpic or"
                           " -msmall-tls: recompile with -fPIC or"
                           " -mno-small-tls)"));
@@ -2010,9 +2017,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
              break;
 
            case bfd_reloc_undefined:
-             r = info->callbacks->undefined_symbol
-               (info, symname, input_bfd, input_section, rel->r_offset,
-                TRUE);
+             (*info->callbacks->undefined_symbol)
+               (info, symname, input_bfd, input_section, rel->r_offset, TRUE);
              break;
 
            case bfd_reloc_outofrange:
@@ -2033,11 +2039,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
            }
 
          if (msg)
-           r = info->callbacks->warning
-             (info, msg, symname, input_bfd, input_section, rel->r_offset);
-
-         if (! r)
-           return FALSE;
+           (*info->callbacks->warning) (info, msg, symname, input_bfd,
+                                        input_section, rel->r_offset);
        }
     }
 
@@ -2054,7 +2057,6 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
                                Elf_Internal_Sym *sym)
 {
   struct elf_cris_link_hash_table * htab;
-  bfd *dynobj;
 
   /* Where in the plt entry to put values.  */
   int plt_off1 = 2, plt_off2 = 10, plt_off3 = 16;
@@ -2086,8 +2088,6 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
       plt_pic_entry = elf_cris_pic_plt_entry_v32;
     }
 
-  dynobj = elf_hash_table (info)->dynobj;
-
   if (h->plt.offset != (bfd_vma) -1)
     {
       asection *splt;
@@ -2130,9 +2130,9 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
-      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
-      srela = bfd_get_linker_section (dynobj, ".rela.plt");
+      splt = htab->root.splt;
+      sgotplt = htab->root.sgotplt;
+      srela = htab->root.srelplt;
       BFD_ASSERT (splt != NULL && sgotplt != NULL
                  && (! has_gotplt || srela != NULL));
 
@@ -2229,8 +2229,8 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
 
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srela = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -2275,8 +2275,10 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
                  && (h->root.type == bfd_link_hash_defined
                      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_linker_section (dynobj, ".rela.bss");
-      BFD_ASSERT (s != NULL);
+      if (h->root.u.def.section == htab->root.sdynrelro)
+       s = htab->root.sreldynrelro;
+      else
+       s = htab->root.srelbss;
 
       rela.r_offset = (h->root.u.def.value
                       + h->root.u.def.section->output_section->vma
@@ -2309,7 +2311,7 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_linker_section (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
   sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
@@ -2318,7 +2320,7 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_linker_section (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -2336,42 +2338,27 @@ elf_cris_finish_dynamic_sections (bfd *output_bfd,
              break;
 
            case DT_PLTGOT:
-             s = bfd_get_section_by_name (output_bfd, ".got");
-             BFD_ASSERT (s != NULL);
-             dyn.d_un.d_ptr = s->vma;
+             dyn.d_un.d_ptr = sgot->output_section->vma + sgot->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_JMPREL:
              /* Yes, we *can* have a .plt and no .plt.rela, for instance
                 if all symbols are found in the .got (not .got.plt).  */
-             s = bfd_get_section_by_name (output_bfd, ".rela.plt");
-             dyn.d_un.d_ptr = s != NULL ? s->vma : 0;
+             s = elf_hash_table (info)->srelplt;
+             dyn.d_un.d_ptr = s != NULL ? (s->output_section->vma
+                                           + s->output_offset) : 0;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_section_by_name (output_bfd, ".rela.plt");
+             s = elf_hash_table (info)->srelplt;
              if (s == NULL)
                dyn.d_un.d_val = 0;
              else
                dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = bfd_get_section_by_name (output_bfd, ".rela.plt");
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -2496,8 +2483,8 @@ cris_elf_gc_sweep_hook (bfd *abfd,
   sym_hashes = elf_sym_hashes (abfd);
   local_got_refcounts = elf_local_got_refcounts (abfd);
 
-  sgot = bfd_get_linker_section (dynobj, ".got");
-  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+  sgot = htab->root.sgot;
+  srelgot = htab->root.srelgot;
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
@@ -2747,13 +2734,11 @@ elf_cris_adjust_gotplt_to_got (struct elf_cris_link_hash_entry *h, void * p)
   else
     {
       /* No GOT entry for this symbol.  We need to create one.  */
-      bfd *dynobj = elf_hash_table (info)->dynobj;
       asection *sgot;
       asection *srelgot;
 
-      BFD_ASSERT (dynobj != NULL);
-      sgot = bfd_get_linker_section (dynobj, ".got");
-      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srelgot = elf_hash_table (info)->srelgot;
 
       /* Put accurate refcounts there.  */
       h->root.got.refcount += h->gotplt_refcount;
@@ -2854,13 +2839,14 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
   struct elf_cris_link_hash_table * htab;
   bfd *dynobj;
   asection *s;
+  asection *srel;
   bfd_size_type plt_entry_size;
 
   htab = elf_cris_hash_table (info);
   if (htab == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
@@ -2928,7 +2914,7 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
            return FALSE;
        }
 
-      s = bfd_get_linker_section (dynobj, ".plt");
+      s = htab->root.splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -2987,13 +2973,13 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
        = htab->next_gotplt_entry;
       htab->next_gotplt_entry += 4;
 
-      s = bfd_get_linker_section (dynobj, ".got.plt");
+      s = htab->root.sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_linker_section (dynobj, ".rela.plt");
+      s = htab->root.srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -3041,23 +3027,30 @@ elf_cris_adjust_dynamic_symbol (struct bfd_link_info *info,
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_linker_section (dynobj, ".dynbss");
-  BFD_ASSERT (s != NULL);
-
   /* We must generate a R_CRIS_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
+
+  if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+    {
+      s = htab->root.sdynrelro;
+      srel = htab->root.sreldynrelro;
+    }
+  else
+    {
+      s = htab->root.sdynbss;
+      srel = htab->root.srelbss;
+    }
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
-      asection *srel;
-
-      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
     }
 
+  BFD_ASSERT (s != NULL);
+
   return _bfd_elf_adjust_dynamic_copy (info, h, s);
 }
 
@@ -3233,7 +3226,8 @@ cris_elf_check_relocs (bfd *abfd,
                 that, we must insist on dynobj being a specific mach.  */
              if (bfd_get_mach (dynobj) == bfd_mach_cris_v10_v32)
                {
-                 (*_bfd_error_handler)
+                 _bfd_error_handler
+                   /* xgettext:c-format */
                    (_("%B, section %A:\n  v10/v32 compatible object %s"
                       " must not contain a PIC relocation"),
                     abfd, sec);
@@ -3251,7 +3245,8 @@ cris_elf_check_relocs (bfd *abfd,
              if (!_bfd_elf_create_got_section (dynobj, info))
                return FALSE;
 
-             sgot = bfd_get_linker_section (dynobj, ".got");
+             sgot = elf_hash_table (info)->sgot;
+             srelgot = elf_hash_table (info)->srelgot;
            }
 
          if (local_got_refcounts == NULL)
@@ -3276,62 +3271,6 @@ cris_elf_check_relocs (bfd *abfd,
          break;
        }
 
-      /* Some relocs require a global offset table (but perhaps not a
-        specific GOT entry).  */
-      switch (r_type)
-       {
-       case R_CRIS_16_DTPREL:
-       case R_CRIS_32_DTPREL:
-         /* Not requesting .got.rela for an executable: the contents
-            of the first entry is constant there.  For a shared
-            library, we need .got.rela for the R_CRIS_DTPMOD
-            relocation at index 3.  */
-         if (!bfd_link_pic (info))
-           break;
-         /* Fall through.  */
-
-       case R_CRIS_32_IE:
-       case R_CRIS_32_GD:
-       case R_CRIS_16_GOT_GD:
-       case R_CRIS_32_GOT_GD:
-       case R_CRIS_32_GOT_TPREL:
-       case R_CRIS_16_GOT_TPREL:
-         /* Fall through.  */
-
-         /* For R_CRIS_16_GOTPLT and R_CRIS_32_GOTPLT, we need a GOT
-            entry only for local symbols.  Unfortunately, we don't know
-            until later on if there's a version script that forces the
-            symbol local.  We must have the .rela.got section in place
-            before we know if the symbol looks global now, so we need
-            to treat the reloc just like for R_CRIS_16_GOT and
-            R_CRIS_32_GOT.  */
-       case R_CRIS_16_GOTPLT:
-       case R_CRIS_32_GOTPLT:
-       case R_CRIS_16_GOT:
-       case R_CRIS_32_GOT:
-         if (srelgot == NULL
-             && (h != NULL || bfd_link_pic (info)))
-           {
-             srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY);
-                 srelgot = bfd_make_section_anyway_with_flags (dynobj,
-                                                               ".rela.got",
-                                                               flags);
-                 if (srelgot == NULL
-                     || !bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
-           }
-         break;
-
-       default:
-         break;
-       }
-
       /* Warn and error for invalid input.  */
       switch (r_type)
        {
@@ -3341,7 +3280,8 @@ cris_elf_check_relocs (bfd *abfd,
        case R_CRIS_32_GD:
          if (bfd_link_pic (info))
            {
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A:\n  relocation %s not valid"
                   " in a shared object;"
                   " typically an option mixup, recompile with -fPIC"),
@@ -3555,7 +3495,8 @@ cris_elf_check_relocs (bfd *abfd,
              && (sec->flags & SEC_READONLY) != 0)
            {
              /* FIXME: How do we make this optionally a warning only?  */
-             (*_bfd_error_handler)
+             _bfd_error_handler
+               /* xgettext:c-format */
                (_("%B, section %A:\n  relocation %s should not"
                   " be used in a shared object; recompile with -fPIC"),
                 abfd,
@@ -3758,10 +3699,10 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (htab == NULL)
     return FALSE;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
   BFD_ASSERT (dynobj != NULL);
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
@@ -3783,7 +3724,7 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
         not actually use these entries.  Reset the size of .rela.got,
         which will cause it to get stripped from the output file
         below.  */
-      s = bfd_get_linker_section (dynobj, ".rela.got");
+      s = htab->root.srelgot;
       if (s != NULL)
        s->size = 0;
     }
@@ -3853,7 +3794,8 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
            }
        }
       else if (! CONST_STRNEQ (name, ".got")
-              && strcmp (name, ".dynbss") != 0)
+              && strcmp (name, ".dynbss") != 0
+              && s != htab->root.sdynrelro)
        {
          /* It's not one of our sections, so don't allocate space.  */
          continue;
@@ -3977,7 +3919,8 @@ elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *h,
     if ((s->section->flags & SEC_READONLY) != 0)
       {
        /* FIXME: How do we make this optionally a warning only?  */
-       (*_bfd_error_handler)
+       _bfd_error_handler
+         /* xgettext:c-format */
          (_("%B, section `%A', to symbol `%s':\n"
             "  relocation %s should not be used"
             " in a shared object; recompile with -fPIC"),
@@ -4017,12 +3960,9 @@ elf_cris_discard_excess_program_dynamics (struct elf_cris_link_hash_entry *h,
          && elf_hash_table (info)->dynamic_sections_created)
        {
          bfd *dynobj = elf_hash_table (info)->dynobj;
-         asection *srelgot;
+         asection *srelgot = elf_hash_table (info)->srelgot;
 
          BFD_ASSERT (dynobj != NULL);
-
-         srelgot = bfd_get_linker_section (dynobj, ".rela.got");
-
          BFD_ASSERT (srelgot != NULL);
 
          srelgot->size -= sizeof (Elf32_External_Rela);
@@ -4032,8 +3972,10 @@ elf_cris_discard_excess_program_dynamics (struct elf_cris_link_hash_entry *h,
         have to export it as a dynamic symbol.  This was already done for
         functions; doing this for all symbols would presumably not
         introduce new problems.  Of course we don't do this if we're
-        exporting all dynamic symbols.  */
-      if (! info->export_dynamic
+        exporting all dynamic symbols, or all data symbols, regardless of
+        them being referenced or not.  */
+      if (! (info->export_dynamic
+            || (h->root.type != STT_FUNC && info->dynamic_data))
          && h->root.dynindx != -1
          && !h->root.def_dynamic
          && !h->root.ref_dynamic)
@@ -4157,11 +4099,12 @@ cris_elf_print_private_bfd_data (bfd *abfd, void * ptr)
 /* Don't mix files with and without a leading underscore.  */
 
 static bfd_boolean
-cris_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+cris_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
+  bfd *obfd = info->output_bfd;
   int imach, omach;
 
-  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
+  if (! _bfd_generic_verify_endian_match (ibfd, info))
     return FALSE;
 
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
@@ -4189,7 +4132,7 @@ cris_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   if (bfd_get_symbol_leading_char (ibfd)
       != bfd_get_symbol_leading_char (obfd))
     {
-      (*_bfd_error_handler)
+      _bfd_error_handler
        (bfd_get_symbol_leading_char (ibfd) == '_'
         ? _("%B: uses _-prefixed symbols, but writing file with non-prefixed symbols")
         : _("%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"),
@@ -4209,7 +4152,7 @@ cris_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
          || (omach == bfd_mach_cris_v32
              && imach != bfd_mach_cris_v10_v32))
        {
-         (*_bfd_error_handler)
+         _bfd_error_handler
            ((imach == bfd_mach_cris_v32)
             ? _("%B contains CRIS v32 code, incompatible"
                 " with previous objects")
@@ -4236,18 +4179,14 @@ cris_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 static bfd_boolean
 cris_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
-  /* Call the base function.  */
-  if (!_bfd_elf_copy_private_bfd_data (ibfd, obfd))
-    return FALSE;
-
-  /* If output is big-endian for some obscure reason, stop here.  */
-  if (_bfd_generic_verify_endian_match (ibfd, obfd) == FALSE)
-    return FALSE;
-
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
 
+  /* Call the base function.  */
+  if (!_bfd_elf_copy_private_bfd_data (ibfd, obfd))
+    return FALSE;
+
   /* Do what we really came here for.  */
   return bfd_set_arch_mach (obfd, bfd_arch_cris, bfd_get_mach (ibfd));
 }
@@ -4393,6 +4332,8 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBUTE_UNUSED,
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
 #define elf_backend_got_elt_size elf_cris_got_elt_size
+#define elf_backend_dtrel_excludes_plt 1
+#define elf_backend_want_dynrelro      1
 
 /* Later, we my want to optimize RELA entries into REL entries for dynamic
    linking and libraries (if it's a win of any significance).  Until then,
This page took 0.034451 seconds and 4 git commands to generate.