Don't decompress the section in bfd_is_section_compressed
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Oct 2012 21:36:50 +0000 (21:36 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 24 Oct 2012 21:36:50 +0000 (21:36 +0000)
* compress.c (bfd_is_section_compressed): Don't decompress the
section.

bfd/ChangeLog
bfd/compress.c

index 599e0bf969b218d59f27cce3d514da0e05022ee0..6125ab5aeaf30303b816a86d737faec83abcc007 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * compress.c (bfd_is_section_compressed): Don't decompress the
+       section.
+
 2012-10-23  Nathan Sidwell  <nathan@codesourcery.com>
 
        * bfd-in.h (bfd_elf_stack_segment_size): Declare.
index 7f947817a173a1712f478c55e2c8c70902c5046c..75d54e49045425b9e46527f7fc7c08652cb00518 100644 (file)
@@ -292,11 +292,20 @@ bfd_boolean
 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.  */
-  return (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
-         && CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+  compressed = (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
+               && CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+
+  /* Restore compress_status.  */
+  sec->compress_status = saved;
+  return compressed;
 }
 
 /*
This page took 0.026648 seconds and 4 git commands to generate.