]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf32-cris.c
[gdb/build] Fix missing implicit constructor call with gcc 4.8
[thirdparty/binutils-gdb.git] / bfd / elf32-cris.c
index 31c06d34ac5a32b94e8f1cbdb290f4c4da90283f..4360b5418c0ff273fc9cfc3b2827622eae0639b0 100644 (file)
@@ -1,5 +1,5 @@
 /* CRIS-specific support for 32-bit ELF.
-   Copyright (C) 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 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.
@@ -453,7 +453,7 @@ cris_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 
 /* Set the howto pointer for an CRIS ELF reloc.  */
 
-static void
+static bfd_boolean
 cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
                         arelent * cache_ptr,
                         Elf_Internal_Rela * dst)
@@ -464,10 +464,13 @@ cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
   if (r_type >= R_CRIS_max)
     {
       /* xgettext:c-format */
-      _bfd_error_handler (_("%pB: invalid CRIS reloc number: %d"), abfd, r_type);
-      r_type = 0;
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
     }
   cache_ptr->howto = & cris_elf_howto_table [r_type];
+  return TRUE;
 }
 
 bfd_reloc_status_type
@@ -886,7 +889,7 @@ static struct bfd_link_hash_table *
 elf_cris_link_hash_table_create (bfd *abfd)
 {
   struct elf_cris_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
+  size_t amt = sizeof (struct elf_cris_link_hash_table);
 
   ret = ((struct elf_cris_link_hash_table *) bfd_zmalloc (amt));
   if (ret == (struct elf_cris_link_hash_table *) NULL)
@@ -1041,7 +1044,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
          symname = (bfd_elf_string_from_elf_section
                     (input_bfd, symtab_hdr->sh_link, sym->st_name));
          if (symname == NULL)
-           symname = bfd_section_name (input_bfd, sec);
+           symname = bfd_section_name (sec);
        }
       else
        {
@@ -1178,10 +1181,10 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
              _bfd_error_handler
                ((h->got.offset == (bfd_vma) -1)
                 /* xgettext:c-format */
-                ? _("%pB, section %pA: No PLT nor GOT for relocation %s"
+                ? _("%pB, section %pA: no PLT nor GOT for relocation %s"
                     " against symbol `%s'")
                 /* xgettext:c-format */
-                : _("%pB, section %pA: No PLT for relocation %s"
+                : _("%pB, section %pA: no PLT for relocation %s"
                     " against symbol `%s'"),
                 input_bfd,
                 input_section,
@@ -2477,7 +2480,7 @@ cris_elf_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED, const asection *plt,
   if ((got = bfd_get_section_by_name (abfd, ".got")) == NULL)
     return (bfd_vma) -1;
 
-  plt_sec_size =  bfd_section_size (plt->owner, plt);
+  plt_sec_size =  bfd_section_size (plt);
   plt_entry_size
     = (bfd_get_mach (abfd) == bfd_mach_cris_v32
        ? PLT_ENTRY_SIZE_V32 : PLT_ENTRY_SIZE);
@@ -3044,7 +3047,7 @@ cris_elf_check_relocs (bfd *abfd,
                {
                  _bfd_error_handler
                    /* xgettext:c-format */
-                   (_("%pB, section %pA:\n  v10/v32 compatible object"
+                   (_("%pB, section %pA: v10/v32 compatible object"
                       " must not contain a PIC relocation"),
                     abfd, sec);
                  return FALSE;
@@ -3316,7 +3319,7 @@ cris_elf_check_relocs (bfd *abfd,
              /* FIXME: How do we make this optionally a warning only?  */
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%pB, section %pA:\n  relocation %s should not"
+               (_("%pB, section %pA: relocation %s should not"
                   " be used in a shared object; recompile with -fPIC"),
                 abfd,
                 sec,
@@ -3482,9 +3485,7 @@ cris_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_CRIS_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
@@ -3512,7 +3513,6 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   struct elf_cris_link_hash_table * htab;
   bfd *dynobj;
   asection *s;
-  bfd_boolean plt;
   bfd_boolean relocs;
 
   htab = elf_cris_hash_table (info);
@@ -3568,7 +3568,6 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
      memory for them.  */
-  plt = FALSE;
   relocs = FALSE;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
@@ -3579,12 +3578,11 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
       /* It's OK to base decisions on the section name, because none
         of the dynobj section names depend upon the input files.  */
-      name = bfd_get_section_name (dynobj, s);
+      name = bfd_section_name (s);
 
       if (strcmp (name, ".plt") == 0)
        {
-         /* Remember whether there is a PLT.  */
-         plt = s->size != 0;
+         ;
        }
       else if (strcmp (name, ".got.plt") == 0)
        {
@@ -3649,49 +3647,7 @@ elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        return FALSE;
     }
 
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-        values later, in elf_cris_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))
-       {
-         if (!add_dynamic_entry (DT_DEBUG, 0))
-           return FALSE;
-       }
-
-      if (plt)
-       {
-         if (!add_dynamic_entry (DT_PLTGOT, 0)
-             || !add_dynamic_entry (DT_PLTRELSZ, 0)
-             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
-             || !add_dynamic_entry (DT_JMPREL, 0))
-           return FALSE;
-       }
-
-      if (relocs)
-       {
-         if (!add_dynamic_entry (DT_RELA, 0)
-             || !add_dynamic_entry (DT_RELASZ, 0)
-             || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
-           return FALSE;
-       }
-
-      if ((info->flags & DF_TEXTREL) != 0)
-       {
-         if (!add_dynamic_entry (DT_TEXTREL, 0))
-           return FALSE;
-         info->flags |= DF_TEXTREL;
-       }
-    }
-#undef add_dynamic_entry
-
-  return TRUE;
+  return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
 }
 
 /* This function is called via elf_cris_link_hash_traverse if we are
@@ -3741,8 +3697,8 @@ elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *h,
        /* FIXME: How do we make this optionally a warning only?  */
        _bfd_error_handler
          /* xgettext:c-format */
-         (_("%pB, section `%pA', to symbol `%s':\n"
-            "  relocation %s should not be used"
+         (_("%pB, section `%pA', to symbol `%s':"
+            " relocation %s should not be used"
             " in a shared object; recompile with -fPIC"),
           s->section->owner,
           s->section,
@@ -3828,9 +3784,8 @@ cris_elf_object_p (bfd *abfd)
 /* Mark presence or absence of leading underscore.  Set machine type
    flags from mach type.  */
 
-static void
-cris_elf_final_write_processing (bfd *abfd,
-                                bfd_boolean linker ATTRIBUTE_UNUSED)
+static bfd_boolean
+cris_elf_final_write_processing (bfd *abfd)
 {
   unsigned long e_flags = elf_elfheader (abfd)->e_flags;
 
@@ -3854,10 +3809,11 @@ cris_elf_final_write_processing (bfd *abfd,
 
     default:
       _bfd_abort (__FILE__, __LINE__,
-                 _("Unexpected machine number"));
+                 _("unexpected machine number"));
     }
 
   elf_elfheader (abfd)->e_flags = e_flags;
+  return _bfd_elf_final_write_processing (abfd);
 }
 
 /* Set the mach type from e_flags value.  */