PR binutils/22875: Visium/ELF: Prevent an out-of-bounds howto table access
[deliverable/binutils-gdb.git] / bfd / elf32-cris.c
index 31c06d34ac5a32b94e8f1cbdb290f4c4da90283f..1c367c44cf9b6c8f50f100033da51286c8f72370 100644 (file)
@@ -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
@@ -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,
@@ -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,
@@ -3741,8 +3744,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,
@@ -3854,7 +3857,7 @@ 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;
This page took 0.025061 seconds and 4 git commands to generate.