Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-cr16c.c
index 5016c6e66a924a19b344895130cccd0859586e6e..35bacbbc6faeebc5cda9e76cdf6c40104e63fe66 100644 (file)
@@ -1,6 +1,5 @@
 /* BFD back-end for National Semiconductor's CR16C ELF
-   Copyright 2004, 2005, 2006, 2007, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
 
 #define USE_REL        1       /* CR16C uses REL relocations instead of RELA.  */
 
-/* The following definition is based on EMPTY_HOWTO macro, 
+/* The following definition is based on EMPTY_HOWTO macro,
    but also initiates the "name" field in HOWTO struct.  */
 #define ONLY_NAME_HOWTO(C) \
   HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
          STRINGX(C), FALSE, 0, 0, FALSE)
 
 /* reloc_map_index array maps CRASM relocation type into a BFD
-   relocation enum. The array's indices are synchronized with 
+   relocation enum. The array's indices are synchronized with
    RINDEX_16C_* indices, created in include/elf/cr16c.h.
    The array is used in:
    1. elf32-cr16c.c : elf_cr16c_reloc_type_lookup().
@@ -166,23 +165,31 @@ elf_cr16c_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   return NULL;
 }
 
-static void
+static bfd_boolean
 elf_cr16c_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
                         arelent *cache_ptr ATTRIBUTE_UNUSED,
                         Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
 {
-  abort ();
+  return FALSE;
 }
 
-static void
+static bfd_boolean
 elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
                             arelent *cache_ptr,
                             Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
 
-  BFD_ASSERT (r_type < (unsigned int) RINDEX_16C_MAX);
+  if (r_type >= RINDEX_16C_MAX)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
   cache_ptr->howto = &elf_howto_table[r_type];
+  return TRUE;
 }
 
 /* Perform a relocation as part of a final link.  */
@@ -229,10 +236,10 @@ cr16c_elf_final_link_relocate (reloc_howto_type *howto,
     case R_NUMBER:
       switch (size)
        {
-       case R_S_16C_08:        /* One byte.  */
+       case R_S_16C_08:        /* One byte.  */
          value = bfd_get_8 (abfd, (char *) data + octets);
          break;
-       case R_S_16C_16:        /* Two bytes. */
+       case R_S_16C_16:        /* Two bytes. */
          sword = bfd_get_16 (abfd, (bfd_byte *) data + octets);
          value = sword;
          break;
@@ -433,7 +440,7 @@ cr16c_elf_final_link_relocate (reloc_howto_type *howto,
     case R_NUMBER:
       switch (size)
        {
-       case R_S_16C_08:        /* One byte.  */
+       case R_S_16C_08:        /* One byte.  */
          if (value > (int) MAX_UBYTE || value < MIN_BYTE)
            return bfd_reloc_overflow;
          value &= 0xFF;
@@ -578,7 +585,7 @@ cr16c_elf_final_link_relocate (reloc_howto_type *howto,
          if (neg2pos)
            {
              /* Change load/stor negative displ opcode
-                to load/stor positive displ opcode.  */
+                to load/stor positive displ opcode.  */
              value = bfd_get_8 (abfd, (char *) data + octets - 3);
              value &= 0xF7;
              value |= 0x2;
@@ -715,26 +722,19 @@ elf32_cr16c_relocate_section (bfd *output_bfd,
        }
       else
        {
-         bfd_boolean unresolved_reloc, warned;
+         bfd_boolean unresolved_reloc, warned, ignored;
 
          RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
                                   r_symndx, symtab_hdr, sym_hashes,
                                   h, sec, relocation,
-                                  unresolved_reloc, warned);
+                                  unresolved_reloc, warned, ignored);
        }
 
-      if (sec != NULL && elf_discarded_section (sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+      if (sec != NULL && discarded_section (sec))
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, 1, relend, howto, 0, contents);
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
        {
          /* This is a relocatable link.  We don't have to change
             anything, unless the reloc is against a section symbol,
@@ -763,24 +763,20 @@ elf32_cr16c_relocate_section (bfd *output_bfd,
              name = (bfd_elf_string_from_elf_section
                      (input_bfd, symtab_hdr->sh_link, sym->st_name));
              if (name == NULL || *name == '\0')
-               name = bfd_section_name (input_bfd, sec);
+               name = bfd_section_name (sec);
            }
 
          switch (r)
            {
            case bfd_reloc_overflow:
-             if (!((*info->callbacks->reloc_overflow)
-                   (info, (h ? &h->root : NULL), name, howto->name,
-                    (bfd_vma) 0, input_bfd, input_section,
-                    rel->r_offset)))
-               return FALSE;
+             (*info->callbacks->reloc_overflow)
+               (info, (h ? &h->root : NULL), name, howto->name,
+                (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
              break;
 
            case bfd_reloc_undefined:
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, name, input_bfd, input_section,
-                    rel->r_offset, TRUE)))
-               return FALSE;
+             (*info->callbacks->undefined_symbol)
+               (info, name, input_bfd, input_section, rel->r_offset, TRUE);
              break;
 
            case bfd_reloc_outofrange:
@@ -800,10 +796,8 @@ elf32_cr16c_relocate_section (bfd *output_bfd,
              /* fall through */
 
            common_error:
-             if (!((*info->callbacks->warning)
-                   (info, msg, name, input_bfd, input_section,
-                    rel->r_offset)))
-               return FALSE;
+             (*info->callbacks->warning) (info, msg, name, input_bfd,
+                                          input_section, rel->r_offset);
              break;
            }
        }
@@ -833,9 +827,9 @@ elf32_cr16c_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
                                      asection *sec,
                                      int *retval)
 {
-  if (strcmp (bfd_get_section_name (abfd, sec), ".fcommon") == 0)
+  if (strcmp (bfd_section_name (sec), ".fcommon") == 0)
     *retval = SHN_CR16C_FCOMMON;
-  else if (strcmp (bfd_get_section_name (abfd, sec), ".ncommon") == 0)
+  else if (strcmp (bfd_section_name (sec), ".ncommon") == 0)
     *retval = SHN_CR16C_NCOMMON;
   else
     return FALSE;
@@ -947,7 +941,7 @@ elf32_cr16c_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED
 }
 
 /* Definitions for setting CR16C target vector.  */
-#define TARGET_LITTLE_SYM              bfd_elf32_cr16c_vec
+#define TARGET_LITTLE_SYM              cr16c_elf32_vec
 #define TARGET_LITTLE_NAME             "elf32-cr16c"
 #define ELF_ARCH                       bfd_arch_cr16c
 #define ELF_MACHINE_CODE               EM_CR
@@ -960,9 +954,9 @@ elf32_cr16c_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED
 #define elf_info_to_howto_rel                  elf_cr16c_info_to_howto_rel
 #define elf_backend_relocate_section           elf32_cr16c_relocate_section
 #define elf_backend_symbol_processing          elf32_cr16c_symbol_processing
-#define elf_backend_section_from_bfd_section   elf32_cr16c_section_from_bfd_section
+#define elf_backend_section_from_bfd_section   elf32_cr16c_section_from_bfd_section
 #define elf_backend_add_symbol_hook            elf32_cr16c_add_symbol_hook
-#define elf_backend_link_output_symbol_hook    elf32_cr16c_link_output_symbol_hook
+#define elf_backend_link_output_symbol_hook    elf32_cr16c_link_output_symbol_hook
 
 #define elf_backend_can_gc_sections     1
 
This page took 0.041323 seconds and 4 git commands to generate.