This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Don't decompress the section in bfd_is_section_compressed


When BFD_DECOMPRESS is set on input, bfd_is_section_compressed doesn't
work since the input is automatically decompressed.  This patch sets
compress_status to COMPRESS_SECTION_NONE before calling
bfd_get_section_contents.  It will be used by GDB.  OK to install?


2012-10-24  H.J. Lu  <>

	* compress.c (bfd_is_section_compressed): Don't decompress the

diff --git a/bfd/compress.c b/bfd/compress.c
index 7f94781..75d54e4 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]