From d3157973ba5cd05eba8d17ead87acf50a7fe4610 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 21 Mar 2017 10:45:16 +0000 Subject: [PATCH] Import FSF binutils patch to fix running readelf on debug info binaries. Resolves: #1434050 --- binutils-2.28-dynamic-section-warning.patch | 33 +++++++++++++++++++++ binutils.spec | 9 +++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 binutils-2.28-dynamic-section-warning.patch diff --git a/binutils-2.28-dynamic-section-warning.patch b/binutils-2.28-dynamic-section-warning.patch new file mode 100644 index 0000000..804286c --- /dev/null +++ b/binutils-2.28-dynamic-section-warning.patch @@ -0,0 +1,33 @@ +diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2017-03-20 17:06:41.260789454 +0000 ++++ binutils-2.28/binutils/readelf.c 2017-03-20 17:08:09.181289807 +0000 +@@ -4965,12 +4965,6 @@ process_program_headers (FILE * file) + section in the DYNAMIC segment. */ + dynamic_addr = segment->p_offset; + dynamic_size = segment->p_filesz; +- /* PR binutils/17512: Avoid corrupt dynamic section info in the segment. */ +- if (dynamic_addr + dynamic_size >= current_file_size) +- { +- error (_("the dynamic segment offset + size exceeds the size of the file\n")); +- dynamic_addr = dynamic_size = 0; +- } + + /* Try to locate the .dynamic section. If there is + a section header table, we can easily locate it. */ +@@ -5005,6 +4999,16 @@ process_program_headers (FILE * file) + warn (_("the .dynamic section is not the first section" + " in the dynamic segment.\n")); + } ++ ++ /* PR binutils/17512: Avoid corrupt dynamic section info in the ++ segment. Check this after matching against the section headers ++ so we don't warn on debuginfo file (which have NOBITS .dynamic ++ sections). */ ++ if (dynamic_addr + dynamic_size >= current_file_size) ++ { ++ error (_("the dynamic segment offset + size exceeds the size of the file\n")); ++ dynamic_addr = dynamic_size = 0; ++ } + break; + + case PT_INTERP: diff --git a/binutils.spec b/binutils.spec index d6fbc66..356d47a 100644 --- a/binutils.spec +++ b/binutils.spec @@ -43,7 +43,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.27 -Release: 20%{?dist} +Release: 21%{?dist} License: GPLv3+ Group: Development/Tools URL: http://sources.redhat.com/binutils @@ -102,6 +102,8 @@ Patch25: binutils-2.27-arm-binary-objects.patch Patch26: binutils-2.27-ppc-fp-attributes.patch # GAS: Emit name, comp_dir and producer strings in .debug_str. Patch27: binutils-2.28-gas-comp_dir.patch +# Have readelf skip checks of the dynamic section when its type is SHT_NOBITS. +Patch28: binutils-2.28-dynamic-section-warning.patch Provides: bundled(libiberty) @@ -254,6 +256,7 @@ using libelf instead of BFD. %patch25 -p1 %patch26 -p1 %patch27 -p1 +%patch28 -p1 # We cannot run autotools as there is an exact requirement of autoconf-2.59. @@ -620,6 +623,10 @@ exit 0 %endif # %{isnative} %changelog +* Tue Mar 21 2017 Nick Clifton 2.27-21 +- Import FSF binutils patch to fix running readelf on debug info binaries. + (#1434050) + * Mon Mar 06 2017 Mark Wielaard 2.27-20 - Backport patch to add support for putting name, comp_dir and producer strings into the .debug_str section.