This is the mail archive of the 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 to handle compressed sections

Just a general comment - I've been seeing a lot of gold patches
lately where gold doesn't have a certain piece of data available at a
certain point... that seems like a really underwhelming reason to
use a big endian size in an otherwise little endian file.  But
as I said earlier, the choice of header format is pretty arbitrary,
and anyone prepared to read DWARF ought to be able to cope with a
simple big endian integer!  So that's fine.

On Mon, Apr 14, 2008 at 04:45:59PM -0700, Craig Silverstein wrote:
> +/* When loading sections, we can either look for ".<name>", or for
> + * ".z<name>", which indicates a compressed section.  */
> +
> +static int
> +section_is_p(asection *sectp, const char *name)

Space before parenthesis.

> +  /* Read the zlib header.  In this case, it should be "ZLIB" followed
> +     by the uncompressed section size, 8 bytes in big-endian order.  */
> +  if (compressed_size < header_size
> +      || strncmp (compressed_buffer, "ZLIB", 4) != 0)
> +    error (_("Dwarf Error: Corrupt DWARF ZLIB header from '%s'"),
> +           bfd_get_filename (abfd));
> +  uncompressed_size = compressed_buffer[4]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[5]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[6]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[7]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[8]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[9]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[10]; uncompressed_size <<= 8;
> +  uncompressed_size += compressed_buffer[11];

You can use bfd_getb64.

>    buf = obstack_alloc (&objfile->objfile_obstack, size);
> +  /* When debugging .o files, we may need to apply relocations; see
> + .
> +     We never compress sections in .o files, so we only need to
> +     try this when the section is not compressed.  */

Use the URL instead, please.  Actually, it'd make me
happy if you couldn't get at these archives via  It
confuses search results...

Aside from that, this is fine to commit.  Do you have write access?
If not, request it using the sourceware form - if you have write
access to binutils then you already do.  Then add yourself to write
after approval in MAINTAINERS and check in the final patch.

The other things needed for this feature are, IMO:

  - A NEWS entry.
  - An entry in the manual.  I'm not sure where, but the format
    of the sections should probably be described in the GDB manual
  - An addition to the "Requirements" section of the GDB manual,
    explaining why you should have zlib.

Could you follow up with those, please?  The other thing I very
much want is an objcopy option to compress DWARF sections, but
that's clearly beyond the call of duty.  That will let GNU ld
users take advantage of this and is probably easier than teaching GNU
ld to compress .debug_info (though that would be nice, too).

Other tools that would benefit from reading such sections include
readelf and addr2line (bfd/dwarf2.c).

Daniel Jacobowitz

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