This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

Re: [PATCH 1/3] simplify decompression code


On Tue, Oct 16, 2012 at 1:45 PM, Tom Tromey <tromey@redhat.com> wrote:
> While working on PR 14704, I realized that BFD has its own code to
> decompress section data.  This code is enabled under the same
> conditions that the zlib code in gdb is enabled.
>
> This patch simplifies gdb by having it use the BFD code in this
> situation.
>
> Built and regtested on x86-64 F16.
>
>         * gdb_bfd.c (zlib_decompress_section): Remove.
>         (gdb_bfd_map_section): Only check for compressed section
>         in mmap case.  Use bfd_get_full_section_contents.
...
> -  /* Check if the file has a 4-byte header indicating compression.  */
> +#ifdef HAVE_MMAP
> +  /* Check if the file has a 4-byte header indicating compression.
> +     Note that we can't use bfd_is_section_compressed here, because
> +     that does not work if the BFD_DECOMPRESS flag is set.  */
>    if (bfd_get_section_size (sectp) > sizeof (header)
>        && bfd_seek (abfd, sectp->filepos, SEEK_SET) == 0
>        && bfd_bread (header, sizeof (header), abfd) == sizeof (header))

Can you try this patch to see if you can use bfd_is_section_compressed
in GDB?

Thanks.


-- 
H.J.
---
diff --git a/bfd/compress.c b/bfd/compress.c
index 294bfd3..2783aaf 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -269,11 +269,22 @@ 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.  */


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