Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
[binutils-gdb.git] / bfd / elf32-arc.c
index 002674be05a8b801f46d614a4372fedb503b7717..cc326bb1427325a236b59310d9aab8e08b57cc05 100644 (file)
@@ -1,5 +1,5 @@
 /* ARC-specific support for 32-bit ELF
-   Copyright (C) 1994-2016 Free Software Foundation, Inc.
+   Copyright (C) 1994-2017 Free Software Foundation, Inc.
    Contributed by Cupertino Miranda (cmiranda@synopsys.com).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -314,9 +314,6 @@ struct elf_arc_link_hash_entry
 struct elf_arc_link_hash_table
 {
   struct elf_link_hash_table elf;
-
-  /* Short-cuts to get to dynamic linker sections.  */
-  asection *srelbss;
 };
 
 static struct bfd_hash_entry *
@@ -375,8 +372,6 @@ arc_elf_link_hash_table_create (bfd *abfd)
       return NULL;
     }
 
-  ret->srelbss = NULL;
-
   ret->elf.init_got_refcount.refcount = 0;
   ret->elf.init_got_refcount.glist = NULL;
   ret->elf.init_got_offset.offset = 0;
@@ -542,8 +537,9 @@ arc_info_to_howto_rel (bfd * abfd ATTRIBUTE_UNUSED,
    object file when linking.  */
 
 static bfd_boolean
-arc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+arc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
+  bfd *obfd = info->output_bfd;
   unsigned short mach_ibfd;
   static unsigned short mach_obfd = EM_NONE;
   flagword out_flags;
@@ -551,7 +547,7 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   asection *sec;
 
    /* Check if we have the same endianess.  */
-  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
+  if (! _bfd_generic_verify_endian_match (ibfd, info))
     return FALSE;
 
   /* Collect ELF flags.  */
@@ -600,6 +596,7 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
     {
       if (mach_ibfd != mach_obfd)
        {
+         /* xgettext:c-format */
          _bfd_error_handler (_("ERROR: Attempting to link %B "
                                "with a binary %s of different architecture"),
                              ibfd, bfd_get_filename (obfd));
@@ -609,6 +606,7 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
        {
          /* Warn if different flags.  */
          _bfd_error_handler
+           /* xgettext:c-format */
            (_("%s: uses different e_flags (0x%lx) fields than "
               "previous modules (0x%lx)"),
             bfd_get_filename (ibfd), (long)in_flags, (long)out_flags);
@@ -803,6 +801,7 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
        {
          if (reloc_data.reloc_addend == 0)
            _bfd_error_handler
+             /* xgettext:c-format */
              (_("%B(%A+0x%lx): CMEM relocation to `%s' is invalid, "
                 "16 MSB should be 0x%04x (value is 0x%lx)"),
               reloc_data.input_section->owner,
@@ -813,6 +812,7 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
               (relocation));
          else
            _bfd_error_handler
+             /* xgettext:c-format */
              (_("%B(%A+0x%lx): CMEM relocation to `%s+0x%lx' is invalid, "
                 "16 MSB should be 0x%04x (value is 0x%lx)"),
               reloc_data.input_section->owner,
@@ -1525,22 +1525,27 @@ elf_arc_relocate_section (bfd *                   output_bfd,
          break;
 
        case bfd_reloc_other:
+         /* xgettext:c-format */
          msg = _("%B(%A): warning: unaligned access to symbol '%s' in the small data area");
          break;
 
        case bfd_reloc_outofrange:
+         /* xgettext:c-format */
          msg = _("%B(%A): internal error: out of range error");
          break;
 
        case bfd_reloc_notsupported:
+         /* xgettext:c-format */
          msg = _("%B(%A): internal error: unsupported relocation error");
          break;
 
        case bfd_reloc_dangerous:
+         /* xgettext:c-format */
          msg = _("%B(%A): internal error: dangerous relocation");
          break;
 
        default:
+         /* xgettext:c-format */
          msg = _("%B(%A): internal error: unknown error");
          break;
        }
@@ -1557,45 +1562,6 @@ elf_arc_relocate_section (bfd *                    output_bfd,
     (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
   == ARC_ELF_DATA ? ((struct elf_arc_link_hash_table *) ((p)->hash)) : NULL)
 
-/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
-   .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
-   hash table.  */
-
-static bfd_boolean
-arc_elf_create_dynamic_sections (bfd *dynobj,
-                                   struct bfd_link_info *info)
-{
-  struct elf_arc_link_hash_table *htab;
-
-  if (!_bfd_elf_create_dynamic_sections (dynobj, info))
-    return FALSE;
-
-  htab = elf_arc_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  if (bfd_link_executable (info))
-    {
-      /* Always allow copy relocs for building executables.  */
-      asection *s = bfd_get_linker_section (dynobj, ".rela.bss");
-      if (s == NULL)
-       {
-         const struct elf_backend_data *bed = get_elf_backend_data (dynobj);
-         s = bfd_make_section_anyway_with_flags (dynobj,
-                                                 ".rela.bss",
-                                                 (bed->dynamic_sec_flags
-                                                  | SEC_READONLY));
-         if (s == NULL
-             || ! bfd_set_section_alignment (dynobj, s,
-                                             bed->s->log_file_align))
-           return FALSE;
-       }
-      htab->srelbss = s;
-    }
-
-  return TRUE;
-}
-
 static struct dynamic_sections
 arc_create_dynamic_sections (bfd * abfd, struct bfd_link_info *info)
 {
@@ -1723,6 +1689,7 @@ elf_arc_check_relocs (bfd *                        abfd,
                  /* bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL);  */
                  name = "UNKNOWN";
                _bfd_error_handler
+                 /* xgettext:c-format */
                  (_("\
 %B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
                    abfd,
@@ -2094,8 +2061,8 @@ elf_arc_adjust_dynamic_symbol (struct bfd_link_info *info,
     {
       struct elf_arc_link_hash_table *arc_htab = elf_arc_hash_table (info);
 
-      BFD_ASSERT (arc_htab->srelbss != NULL);
-      arc_htab->srelbss->size += sizeof (Elf32_External_Rela);
+      BFD_ASSERT (arc_htab->elf.srelbss != NULL);
+      arc_htab->elf.srelbss->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
     }
 
@@ -2150,16 +2117,16 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
       if (h->dynindx == -1
          || (h->root.type != bfd_link_hash_defined
              && h->root.type != bfd_link_hash_defweak)
-         || arc_htab->srelbss == NULL)
+         || arc_htab->elf.srelbss == NULL)
        abort ();
 
       bfd_vma rel_offset = (h->root.u.def.value
                            + h->root.u.def.section->output_section->vma
                            + h->root.u.def.section->output_offset);
 
-      bfd_byte * loc = arc_htab->srelbss->contents
-       + (arc_htab->srelbss->reloc_count * sizeof (Elf32_External_Rela));
-      arc_htab->srelbss->reloc_count++;
+      bfd_byte * loc = arc_htab->elf.srelbss->contents
+       + (arc_htab->elf.srelbss->reloc_count * sizeof (Elf32_External_Rela));
+      arc_htab->elf.srelbss->reloc_count++;
 
       Elf_Internal_Rela rel;
       rel.r_addend = 0;
@@ -2229,7 +2196,6 @@ elf_arc_finish_dynamic_sections (bfd * output_bfd,
              GET_SYMBOL_OR_SECTION (DT_PLTGOT, NULL, ".plt")
              GET_SYMBOL_OR_SECTION (DT_JMPREL, NULL, ".rela.plt")
              GET_SYMBOL_OR_SECTION (DT_PLTRELSZ, NULL, ".rela.plt")
-             GET_SYMBOL_OR_SECTION (DT_RELASZ, NULL, ".rela.plt")
              GET_SYMBOL_OR_SECTION (DT_VERSYM, NULL, ".gnu.version")
              GET_SYMBOL_OR_SECTION (DT_VERDEF, NULL, ".gnu.version_d")
              GET_SYMBOL_OR_SECTION (DT_VERNEED, NULL, ".gnu.version_r")
@@ -2279,12 +2245,6 @@ elf_arc_finish_dynamic_sections (bfd * output_bfd,
                    do_it = TRUE;
                    break;
 
-                 case DT_RELASZ:
-                   if (s != NULL)
-                     internal_dyn.d_un.d_val -= s->size;
-                   do_it = TRUE;
-                   break;
-
                  default:
                    break;
                }
@@ -2359,7 +2319,7 @@ elf_arc_size_dynamic_sections (bfd * output_bfd,
 
       /* Set the contents of the .interp section to the
         interpreter.  */
-      if (!bfd_link_pic (info))
+      if (!bfd_link_pic (info) && !info->nointerp)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -2600,7 +2560,7 @@ elf32_arc_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 
 #define elf_backend_relocate_section        elf_arc_relocate_section
 #define elf_backend_check_relocs            elf_arc_check_relocs
-#define elf_backend_create_dynamic_sections  arc_elf_create_dynamic_sections
+#define elf_backend_create_dynamic_sections  _bfd_elf_create_dynamic_sections
 
 #define elf_backend_reloc_type_class           elf32_arc_reloc_type_class
 
@@ -2617,6 +2577,7 @@ elf32_arc_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 #define elf_backend_rela_plts_and_copies_p 1
 #define elf_backend_want_plt_sym       0
 #define elf_backend_got_header_size    12
+#define elf_backend_dtrel_excludes_plt 1
 
 #define elf_backend_may_use_rel_p      0
 #define elf_backend_may_use_rela_p     1