2010-06-28 21:39:15 UTC
support for compressed debug sections generated by the linker:
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
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
(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.
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-in2.h: Regenerate.
* compress.c (bfd_compress_section_contents): New function.
* dwarf2.c (read_and_uncompress_section): New function.
(read_section): Call it.
* libbfd.h: Regenerate.
* objdump.c (load_specific_debug_section): Decompress section contents
before applying relocations.
* readelf.c (load_specific_debug_section): Update section size after
* as.c (parse_args): Add --compress-debug-sections and
* 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.