[PATCH] readelf: Change some errors to warnings
"H.J. Lu" <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <CAMe9rOokCox6tY_F8dJ2FZU4C82F1ZPq8gizOyWakVW3ARzd6g@mail.gmail.com> |
Change readelf to return error if there are errors in inputs. Since invalid LEB and sh_entsize values in the readelf input aren't fatal errors, replace error with warn for these to avoid FAIL: readelf -Wwi pr26548e (reason: unexpected output) FAIL: readelf -SW corrupt-1 (reason: unexpected output) PR binutils/34500 * dwarf.h (report_leb_status): Replace error with warn. * readelf.c (process_section_headers): Replace error with warn on invalid sh_entsize value. (main): Return error if seen_elf_error returns true. -- H.J.
0001-readelf-Change-some-errors-to-warnings.patch
(text/x-patch, 2.6 KB)
From 75644c5bf682d0f7c1dfd1f8ad03ccd629170cd5 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <[email protected]> Date: Sun, 9 Aug 2026 08:17:46 +0800 Subject: [PATCH] readelf: Change some errors to warnings Change readelf to return error if there are errors in inputs. Since invalid LEB and sh_entsize values in the readelf input aren't fatal errors, replace error with warn for these to avoid FAIL: readelf -Wwi pr26548e (reason: unexpected output) FAIL: readelf -SW corrupt-1 (reason: unexpected output) PR binutils/34500 * dwarf.h (report_leb_status): Replace error with warn. * readelf.c (process_section_headers): Replace error with warn on invalid sh_entsize value. (main): Return error if seen_elf_error returns true. Signed-off-by: H.J. Lu <[email protected]> --- binutils/dwarf.h | 4 ++-- binutils/readelf.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/binutils/dwarf.h b/binutils/dwarf.h index e6b51bf368e..fe61a1e5359 100644 --- a/binutils/dwarf.h +++ b/binutils/dwarf.h @@ -537,9 +537,9 @@ static inline void report_leb_status (int status) { if ((status & 1) != 0) - error (_("end of data encountered whilst reading LEB\n")); + warn (_("end of data encountered whilst reading LEB\n")); else if ((status & 2) != 0) - error (_("read LEB value is too large to store in destination variable\n")); + warn (_("read LEB value is too large to store in destination variable\n")); } #define SKIP_ULEB(start, end) \ diff --git a/binutils/readelf.c b/binutils/readelf.c index 65d3fd2ea8e..478c55bb1ee 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -8811,10 +8811,10 @@ process_section_headers (Filedata * filedata) uint64_t expected_entsize = is_32bit_elf ? size32 : size64; \ if (section->sh_entsize != expected_entsize) \ { \ - error (_("Section %d has invalid sh_entsize of %" PRIx64 "\n"), \ - i, section->sh_entsize); \ - error (_("(Using the expected size of %" PRIx64 " for the rest of this dump)\n"), \ - expected_entsize); \ + warn (_("Section %d has invalid sh_entsize of %" PRIx64 "\n"), \ + i, section->sh_entsize); \ + warn (_("(Using the expected size of %" PRIx64 " for the rest of this dump)\n"), \ + expected_entsize); \ section->sh_entsize = expected_entsize; \ } \ } \ @@ -25619,7 +25619,7 @@ main (int argc, char ** argv) while (optind < argc) { clear_elf_error (); - if (! process_file (argv[optind++])) + if (! process_file (argv[optind++]) || seen_elf_error ()) err = true; } -- 2.55.0