[binutils/f20] Fix detection of uncompressed .debug_str sections. Resolves #1082370

Nicholas Clifton nickc at fedoraproject.org
Mon Apr 28 15:27:06 UTC 2014


commit 82dfc96b81a93c21c467967f7a2152ea98af7b21
Author: Nick Clifton <nickc at redhat.com>
Date:   Mon Apr 28 16:26:28 2014 +0100

    Fix detection of uncompressed .debug_str sections.
    Resolves #1082370

 binutils-2.23.2-fake-zlib-sections.patch |   55 ++++++++++++++++++++++++++++++
 binutils.spec                            |    8 ++++-
 2 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/binutils-2.23.2-fake-zlib-sections.patch b/binutils-2.23.2-fake-zlib-sections.patch
new file mode 100644
index 0000000..b8d50c1
--- /dev/null
+++ b/binutils-2.23.2-fake-zlib-sections.patch
@@ -0,0 +1,55 @@
+*** ../binutils-2.23.2.orig/bfd/compress.c	2014-04-28 16:12:03.743891740 +0100
+--- bfd/compress.c	2014-04-28 16:20:28.980834659 +0100
+***************
+*** 25,30 ****
+--- 25,31 ----
+  #ifdef HAVE_ZLIB_H
+  #include <zlib.h>
+  #endif
++ #include "safe-ctype.h"
+  
+  #ifdef HAVE_ZLIB_H
+  static bfd_boolean
+*************** bfd_boolean
+*** 272,282 ****
+  bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
+  {
+    bfd_byte compressed_buffer [12];
+  
+    /* Read the zlib header.  In this case, it should be "ZLIB" followed
+       by the uncompressed section size, 8 bytes in big-endian order.  */
+!   return (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
+! 	  && CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+  }
+  
+  /*
+--- 273,301 ----
+  bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
+  {
+    bfd_byte compressed_buffer [12];
++   unsigned int saved = sec->compress_status;
++   bfd_boolean compressed;
++ 
++   /* Don't decompress the section.  */
++   sec->compress_status = COMPRESS_SECTION_NONE;
+  
+    /* Read the zlib header.  In this case, it should be "ZLIB" followed
+       by the uncompressed section size, 8 bytes in big-endian order.  */
+!   compressed = (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
+! 		&& CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+! 
+!   /* Check for the pathalogical case of a debug string section that
+!      contains the string ZLIB.... as the first entry.  We assume that
+!      no uncompressed .debug_str section would ever be big enough to
+!      have the first byte of its (big-endian) size be non-zero.  */
+!   if (compressed
+!       && strcmp (sec->name, ".debug_str") == 0
+!       && ISPRINT (compressed_buffer[4]))
+!     compressed = FALSE;
+! 
+!   /* Restore compress_status.  */
+!   sec->compress_status = saved;
+!   return compressed;
+  }
+  
+  /*
diff --git a/binutils.spec b/binutils.spec
index 3938747..0af5c80 100644
--- a/binutils.spec
+++ b/binutils.spec
@@ -27,7 +27,7 @@ Name: %{?cross}binutils%{?_with_debug:-debug}
 # official binutils release happens (2.24.0) we will be able to restore
 # Version to an honest value and everything will be good again.
 Version: 2.23.88.0.1
-Release: 16%{?dist}
+Release: 17%{?dist}
 License: GPLv3+
 Group: Development/Tools
 URL: http://sources.redhat.com/binutils
@@ -84,6 +84,8 @@ Patch24: binutils-2.23.51.0.1-readelf-flush-stdout.patch
 Patch25: binutils-2.23.2-i386-dis.patch
 # Fix decoding of abstract instance names using DW_FORM_ref_addr.
 Patch26: binutils-2.23.2-DW_FORM_ref_addr.patch
+# Fix detections of uncompressed .debug_str sections that look like they have been compressed.
+Patch27: binutils-2.23.2-fake-zlib-sections.patch
 
 Provides: bundled(libiberty)
 
@@ -215,6 +217,7 @@ using libelf instead of BFD.
 %patch24 -p0 -b .flush~ 
 %patch25 -p0 -b .i386-dis~ 
 %patch26 -p0 -b .ref_addr~ 
+%patch27 -p0 -b .fake-zlib~ 
 
 # We cannot run autotools as there is an exact requirement of autoconf-2.59.
 
@@ -520,6 +523,9 @@ exit 0
 %endif # %{isnative}
 
 %changelog
+* Mon Apr 28 2014 Nick Clifton <nickc at redhat.com> - 2.23.88.0.1-17
+- Fix detection of uncompressed .debug_str sections.  (#1082370)
+
 * Tue Jan 28 2014 Nick Clifton <nickc at redhat.com> - 2.23.88.0.1-16
 - Fix decoding of abbrevs using a DW_FORM_ref_addr attribute.  (#1056797)
 


More information about the scm-commits mailing list