This is the mail archive of the binutils@sourceware.org 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] Add --compress-debug-sections option to gas


A couple of years ago, Craig Silverstein submitted a patch to add
support for compressed debug sections generated by the linker:

  http://sourceware.org/ml/binutils/2008-06/msg00203.html

The attached patch extends this support to the assembler, adding a new
--compress-debug-sections option to gas, and adding the necessary
support (and fixing a couple of bugs in the original patch) for
reading compressed sections in relocatables to bfd, objdump, and
readelf.

Tested on x86_64 by compiling with and without
-Wa,--compress-debug-sections, and comparing readelf -w output and
objdump -W output. No regressions in the test suite.

A patch for gold to read files with compressed debug sections is in progress.

I have to admit that I'm not happy with a couple of things:

(1) In both bfd/dwarf2.c and binutils/objdump.c, in order to
uncompress the section before relocating it, I call
bfd_get_section_contents() to get the unrelocated section contents,
then decompress the contents and put a pointer to the decompressed
contents in sec->contents, setting the SEC_IN_MEMORY flag so that
bfd_simple_get_relocated_section_contents() would not go read the
section again. I couldn't find a simpler way to apply relocations
after decompression.

(2) In gas/write.c, I used a similar trick to signal write_contents()
that the frags had already been collected and compressed. An
alternative I considered was to simply replace the frag list with a
single frag containing the entire compressed section contents, but
that seemed a bit more complicated.

Advice on these issues is welcome.

-cary

p.s. I'm not sure why my regenerated libbfd.h is different from the
original -- nothing changed except for parameters to
bfd_generic_get_relocated_section_contents() that used to be unnamed.
Did "make headers" change behavior since the last time that file was
regenerated? Should I just leave this out of the patch?


bfd/ChangeLog:

        * bfd-in2.h: Regenerate.
        * compress.c (bfd_compress_section_contents): New function.
        * dwarf2.c (read_and_uncompress_section): New function.
        (read_section): Call it.
        (find_line): Likewise.
        * libbfd.h: Regenerate.

binutils/ChangeLog:

        * objdump.c (load_specific_debug_section): Decompress section contents
        before applying relocations.
        * readelf.c (load_specific_debug_section): Update section size after
        decompression.

gas/ChangeLog:

        * as.c (parse_args): Add --compress-debug-sections and
        --nocompress-debug-sections.
        * as.h (flag_compress_debug): New variable.
        * write.c (compress_debug): New function.
        (write_contents): Check for uncompressed section.
        (write_object_file): Compress debug sections if requested.

Attachment: compress-debug-patch.txt
Description: Text document


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