]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR25196, abort in rewrite_elf_program_header
authorAlan Modra <amodra@gmail.com>
Mon, 18 Nov 2019 02:01:55 +0000 (12:31 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 18 Nov 2019 11:36:09 +0000 (22:06 +1030)
This patch introduces a new "sorry, cannot handle this file" bfd error
status.  The idea is to use this error in cases where bfd hasn't found
a bfd_bad_value error, ie. an input file or set of options that are
invalid, but rather an input file that is simply too difficult to
process.  Typically this might happen with fuzzed object files such as
the one in the PR, a wildly improbable core file.  Some things are
just not worth wasting time over to fix "properly".

PR 25196
* bfd.c (bfd_error_type): Add bfd_error_sorry.
(bfd_errmsgs): Likewise.
* elf.c (rewrite_elf_program_header): Don't abort on confused
lma/alignment.  Replace bfd_error_bad_value with bfd_error_sorry.
(_bfd_elf_validate_reloc): Use bfd_error_sorry.
(_bfd_elf_final_write_processing): Likewise.
* bfd-in2.h: Regenerate.

bfd/ChangeLog
bfd/bfd-in2.h
bfd/bfd.c
bfd/elf.c

index 9370b7a8d04618d347b3ef2adb563fdcfde22f61..21842080380283a58eb2c19756123ec53ed6864e 100644 (file)
@@ -1,3 +1,14 @@
+2019-11-18  Alan Modra  <amodra@gmail.com>
+
+       PR 25196
+       * bfd.c (bfd_error_type): Add bfd_error_sorry.
+       (bfd_errmsgs): Likewise.
+       * elf.c (rewrite_elf_program_header): Don't abort on confused
+       lma/alignment.  Replace bfd_error_bad_value with bfd_error_sorry.
+       (_bfd_elf_validate_reloc): Use bfd_error_sorry.
+       (_bfd_elf_final_write_processing): Likewise.
+       * bfd-in2.h: Regenerate.
+
 2019-11-12  Jim Wilson  <jimw@sifive.com>
 
        PR 25181
index 3244905b4563894e18d1d0dc3af0864777ebb073..a00dfa35150528dbbe3e411b71c93d457c4cdda7 100644 (file)
@@ -6964,6 +6964,7 @@ typedef enum bfd_error
   bfd_error_bad_value,
   bfd_error_file_truncated,
   bfd_error_file_too_big,
+  bfd_error_sorry,
   bfd_error_on_input,
   bfd_error_invalid_error_code
 }
index 94e9f27e9d0b5cf85c51b187303c2584ab82ede8..e92213b543eb5daaec392fd93cf0a17accbf684a 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -655,6 +655,7 @@ CODE_FRAGMENT
 .  bfd_error_bad_value,
 .  bfd_error_file_truncated,
 .  bfd_error_file_too_big,
+.  bfd_error_sorry,
 .  bfd_error_on_input,
 .  bfd_error_invalid_error_code
 .}
@@ -688,6 +689,7 @@ const char *const bfd_errmsgs[] =
   N_("bad value"),
   N_("file truncated"),
   N_("file too big"),
+  N_("sorry, cannot handle this file"),
   N_("error reading %s: %s"),
   N_("#<invalid error code>")
 };
index be060d579ccec113b6222787faba5fccc907bbd5..e10099842b805d9278d234ad8319063dc6285960 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7324,7 +7324,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
                                          : 0),
                                       output_section->alignment_power)
                          != output_section->lma)
-                       abort ();
+                       goto sorry;
                    }
                  else
                    {
@@ -7363,7 +7363,8 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
             negative size - or segments that do not contain any sections.  */
          if (map->count == 0)
            {
-             bfd_set_error (bfd_error_bad_value);
+           sorry:
+             bfd_set_error (bfd_error_sorry);
              free (sections);
              return FALSE;
            }
@@ -9277,7 +9278,7 @@ _bfd_elf_validate_reloc (bfd *abfd, arelent *areloc)
   /* xgettext:c-format */
   _bfd_error_handler (_("%pB: %s unsupported"),
                      abfd, areloc->howto->name);
-  bfd_set_error (bfd_error_bad_value);
+  bfd_set_error (bfd_error_sorry);
   return FALSE;
 }
 
@@ -12249,7 +12250,7 @@ _bfd_elf_final_write_processing (bfd *abfd)
            _bfd_error_handler (_("symbol type STT_GNU_IFUNC is unsupported"));
          if (elf_tdata (abfd)->has_gnu_osabi & elf_gnu_osabi_unique)
            _bfd_error_handler (_("symbol binding STB_GNU_UNIQUE is unsupported"));
-         bfd_set_error (bfd_error_bad_value);
+         bfd_set_error (bfd_error_sorry);
          return FALSE;
        }
     }