Discussion:
[patch] Add --compress-debug-sections option to gas
Cary Coutant
2010-06-28 21:39:15 UTC
Permalink
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.
Alan Modra
2010-06-29 08:07:46 UTC
Permalink
Post by Cary Coutant
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.
Someone hand edited the file. Now fixed.
Post by Cary Coutant
+bfd_boolean
+bfd_compress_section_contents (bfd_byte **buffer, bfd_size_type *size)
+{
+#ifndef HAVE_ZLIB_H
+ /* These are just to quiet gcc. */
+ buffer = 0;
+ size = 0;
Except they don't quiet gcc-4.6. Just add ATTRIBUTE_UNUSED to the params.
Post by Cary Coutant
+ compressed_buffer[4] = uncompressed_size >> 56;
This is going to warn and thus break the build when bfd_size_type is
32-bits, as can happen on a 32-bit host supporting 32-bit targets.
Post by Cary Coutant
@@ -1297,6 +1368,20 @@ write_contents (bfd *abfd ATTRIBUTE_UNUSED,
addressT offset = 0;
fragS *f;
+ if (bfd_get_section_flags (abfd, sec) & SEC_IN_MEMORY)
SEC_IN_MEMORY isn't sufficient. Other sections will be SEC_IN_MEMORY
too, eg. SHT_GROUP sections. I think your alternate approach of
twiddling the frag list is indicated.
--
Alan Modra
Australia Development Lab, IBM
Cary Coutant
2010-06-29 18:42:37 UTC
Permalink
Post by Cary Coutant
+bfd_boolean
+bfd_compress_section_contents (bfd_byte **buffer, bfd_size_type *size)
+{
+#ifndef HAVE_ZLIB_H
+  /* These are just to quiet gcc.  */
+  buffer = 0;
+  size = 0;
Except they don't quiet gcc-4.6.  Just add ATTRIBUTE_UNUSED to the params.
Good idea, thanks.
Post by Cary Coutant
+  compressed_buffer[4] = uncompressed_size >> 56;
This is going to warn and thus break the build when bfd_size_type is
32-bits, as can happen on a 32-bit host supporting 32-bit targets.
OK, I'll fix it to fill in the buffer from the other direction,
shifting 8 bits at a time.
Post by Cary Coutant
@@ -1297,6 +1368,20 @@ write_contents (bfd *abfd ATTRIBUTE_UNUSED,
   addressT offset = 0;
   fragS *f;
+  if (bfd_get_section_flags (abfd, sec) & SEC_IN_MEMORY)
SEC_IN_MEMORY isn't sufficient.  Other sections will be SEC_IN_MEMORY
too, eg. SHT_GROUP sections.  I think your alternate approach of
twiddling the frag list is indicated.
OK, I'll try that.

Thanks for the review!

-cary
Cary Coutant
2010-07-02 01:03:02 UTC
Permalink
SEC_IN_MEMORY isn't sufficient.  Other sections will be SEC_IN_MEMORY
too, eg. SHT_GROUP sections.  I think your alternate approach of
twiddling the frag list is indicated.
Here's an updated patch that builds a new frag list. Since a frag
requires the data to follow the struct immediately, it didn't work
with the nice clean interface I added to bfd. It did lead to a more
efficient way of compressing, however: I now just stream each frag
through the compression engine, building new compressed frags as the
compressed data comes out, using the same obstack. At the end, I
replace the old frag list with the new one. I had to move the
zlib-specific code into a separate source file, because I can't
include as.h and zlib.h in the same file.

-cary


bfd/ChangeLog:

* compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED.
* dwarf2.c (read_and_uncompress_section): New function.
(read_section): Call it.
(find_line): Likewise.

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:

* Makefile.am: Add compress-debug.c and compress-debug.h.
* Makefile.in: Regenerate.
* config.in: Add HAVE_ZLIB_H.
* configure.in: Check for zlib.h.
* configure: Regenerate.

* as.c (parse_args): Add --compress-debug-sections and
--nocompress-debug-sections.
* as.h (flag_compress_debug): New variable.
* compress-debug.c: New file.
* compress-debug.h: New file.
* write.c: Include compress-debug.h.
(compress_debug): New function.
(write_object_file): Compress debug sections if requested.
Alan Modra
2010-07-02 02:29:17 UTC
Permalink
On Thu, Jul 01, 2010 at 06:03:02PM -0700, Cary Coutant wrote:
[snip]
+ /* Reserve all the space we can. If none is available, force
+ the obstack to grow by at least as many bytes as we have
+ remaining in the input stream. */
+ room = obstack_room (ob);
+ if (room <= 0)
+ room = strm->avail_in;
+ obstack_blank (ob, room);
obstack_blank_fast. You don't really need to zero the mem do you?
+ strm->next_out = (Bytef *) obstack_next_free (ob) - room;
+ strm->avail_out = room;
+ x = deflate (strm, Z_NO_FLUSH);
+ if (x != Z_OK)
+ return -1;
+
+ /* Return unused space. */
+ if (strm->avail_out > 0)
+ obstack_blank (ob, -((int) strm->avail_out));
obstack_blank_fast again, similarly in compress_finish.

[snip]
+ /* Create a new frag to contain the "ZLIB" header. */
+ obstack_blank (ob, SIZEOF_STRUCT_FRAG + 12);
You should use frag_alloc here and later where you create frags
+ first_newf = (fragS *) obstack_finish (ob);
+ memset (first_newf, 0, SIZEOF_STRUCT_FRAG);
+ first_newf->fr_type = rs_fill;
otherwise these struct references might segfault on some architectures
due to misalignment. With these issues fixed the patch is OK to
commit.
--
Alan Modra
Australia Development Lab, IBM
Cary Coutant
2010-07-02 20:45:51 UTC
Permalink
+      /* Reserve all the space we can.  If none is available, force
+      the obstack to grow by at least as many bytes as we have
+      remaining in the input stream.  */
+      room = obstack_room (ob);
+      if (room <= 0)
+     room = strm->avail_in;
+      obstack_blank (ob, room);
obstack_blank_fast.  You don't really need to zero the mem do you?
In the (room <= 0) case, I needed to use obstack_blank so that it
would reallocate the current obstack object. I wasn't happy with that
approach anyway, since it didn't make effective use of the obstack, so
I've rewritten the patch to fill each new compressed frag until
there's no room left in the current obstack chunk, at which point it
will create another frag (instead of creating one new frag for each
original frag). With this rewrite, the isolation of the zlib interface
is also cleaner.
+  /* Create a new frag to contain the "ZLIB" header.  */
+  obstack_blank (ob, SIZEOF_STRUCT_FRAG + 12);
You should use frag_alloc here and later where you create frags
I couldn't use frag_alloc because I was relying on obstack_blank
reallocating as necessary, and I needed the frag structure to get
reallocated with the data that followed. With this new patch, I can
now use frag_alloc as you suggest.

Since this new patch changes a bit more than you asked for, I'll wait
for a new approval.

(Side question: I'm puzzled by the alignment stuff in frag_alloc() --
it seems to be setting the alignment mask to 0 before calling
obstack_alloc(). Doesn't that mean that the frag structure will be
allocated on an arbitrary byte boundary?)

(Also: in relax_frag(), I found the following code:

newf = frag_alloc (ob);
obstack_blank_fast (ob, fragP->fr_var);
obstack_finish (ob);

But I couldn't find any code that would guarantee that there was
enough room for the obstack_blank_fast call to succeed. Am I missing
something, or is there a potential bug there?)

Thanks so much for the quick and helpful reviews!

-cary


bfd/ChangeLog:

* compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED.
* dwarf2.c (read_and_uncompress_section): New function.
(read_section): Call it.
(find_line): Likewise.

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:

* Makefile.am: Add compress-debug.c and compress-debug.h.
* Makefile.in: Regenerate.
* config.in: Add HAVE_ZLIB_H.
* configure.in: Check for zlib.h.
* configure: Regenerate.

* as.c (parse_args): Add --compress-debug-sections and
--nocompress-debug-sections.
* as.h (flag_compress_debug): New variable.
* compress-debug.c: New file.
* compress-debug.h: New file.
* write.c: Include compress-debug.h.
(compress_frag): New function.
(compress_debug): New function.
(write_object_file): Compress debug sections if requested.
Alan Modra
2010-07-03 10:42:27 UTC
Permalink
Post by Cary Coutant
In the (room <= 0) case, I needed to use obstack_blank so that it
OK, I was confused about what obstack_blank did anyway..
Post by Cary Coutant
(Side question: I'm puzzled by the alignment stuff in frag_alloc() --
it seems to be setting the alignment mask to 0 before calling
obstack_alloc(). Doesn't that mean that the frag structure will be
allocated on an arbitrary byte boundary?)
No. I haven't looked at this code in any detail for a long time, but
I think the idea is that the first obstack_alloc (ob, 0) call sets up
ob->next_free to the required boundary. So when you alloc the actual
frag header with the next call it will be properly aligned. The
alignment mask is zeroed for the header alloc so no padding is added
*after* the header. We want the frag literal field following
immediately after the header.
Post by Cary Coutant
newf = frag_alloc (ob);
obstack_blank_fast (ob, fragP->fr_var);
obstack_finish (ob);
But I couldn't find any code that would guarantee that there was
enough room for the obstack_blank_fast call to succeed. Am I missing
something, or is there a potential bug there?)
I think it's a bug.
Post by Cary Coutant
* compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED.
* dwarf2.c (read_and_uncompress_section): New function.
(read_section): Call it.
(find_line): Likewise.
* objdump.c (load_specific_debug_section): Decompress section contents
before applying relocations.
* readelf.c (load_specific_debug_section): Update section size after
decompression.
* Makefile.am: Add compress-debug.c and compress-debug.h.
* Makefile.in: Regenerate.
* config.in: Add HAVE_ZLIB_H.
* configure.in: Check for zlib.h.
* configure: Regenerate.
* as.c (parse_args): Add --compress-debug-sections and
--nocompress-debug-sections.
* as.h (flag_compress_debug): New variable.
* compress-debug.c: New file.
* compress-debug.h: New file.
* write.c: Include compress-debug.h.
(compress_frag): New function.
(compress_debug): New function.
(write_object_file): Compress debug sections if requested.
OK.
--
Alan Modra
Australia Development Lab, IBM
Cary Coutant
2010-07-03 20:54:43 UTC
Permalink
        * compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED.
        * dwarf2.c (read_and_uncompress_section): New function.
        (read_section): Call it.
        (find_line): Likewise.
        * objdump.c (load_specific_debug_section): Decompress section contents
        before applying relocations.
        * readelf.c (load_specific_debug_section): Update section size after
        decompression.
        * Makefile.am: Add compress-debug.c and compress-debug.h.
        * Makefile.in: Regenerate.
        * config.in: Add HAVE_ZLIB_H.
        * configure.in: Check for zlib.h.
        * configure: Regenerate.
        * as.c (parse_args): Add --compress-debug-sections and
        --nocompress-debug-sections.
        * as.h (flag_compress_debug): New variable.
        * compress-debug.c: New file.
        * compress-debug.h: New file.
        * write.c: Include compress-debug.h.
        (compress_frag): New function.
        (compress_debug): New function.
        (write_object_file): Compress debug sections if requested.
OK.
Thanks, committed.

-cary
Hans-Peter Nilsson
2010-07-03 23:28:26 UTC
Permalink
Post by Cary Coutant
        * Makefile.am: Add compress-debug.c and compress-debug.h.
        * Makefile.in: Regenerate.
        * config.in: Add HAVE_ZLIB_H.
        * configure.in: Check for zlib.h.
        * configure: Regenerate.
        * as.c (parse_args): Add --compress-debug-sections and
        --nocompress-debug-sections.
        * as.h (flag_compress_debug): New variable.
        * compress-debug.c: New file.
        * compress-debug.h: New file.
        * write.c: Include compress-debug.h.
        (compress_frag): New function.
        (compress_debug): New function.
        (write_object_file): Compress debug sections if requested.
OK.
Thanks, committed.
Looks like you forgot to commit compress-debug.[ch], my trusted
autotester got (cutnpasted linewrapped from my log):
gcc -O2 -m32 -DHAVE_CONFIG_H -I.
-I/tmp/hpautotest-binutils/bsrc/src/gas -I.
-I/tmp/hpautotest-bin\
utils/bsrc/src/gas -I../bfd
-I/tmp/hpautotest-binutils/bsrc/src/gas/config
-I/tmp/hpautotest-binuti\
ls/bsrc/src/gas/../include
-I/tmp/hpautotest-binutils/bsrc/src/gas/..
-I/tmp/hpautotest-binutils/bs\
rc/src/gas/../bfd -DLOCALEDIR="\"/usr/local/share/locale\"" -W
-Wall -Wstrict-prototypes -Wmissing\
-prototypes -Wshadow -Werror -g -O2 -MT atof-generic.o -MD -MP
-MF .deps/atof-generic.Tpo -c -o ato\
f-generic.o /tmp/hpautotest-binutils/bsrc/src/gas/atof-generic.c
mv -f .deps/atof-generic.Tpo .deps/atof-generic.Po
make[4]: *** make[4]: Leaving directory
`/tmp/hpautotest-binutils/cris-axis-linux-gnu/gas'
No rule to make target `compress-debug.o', needed by `as-new'.
Stop.

and no trace of it when checking manually.

brgds, H-P
PS: usually a missing "cvs add"...
Alan Modra
2010-07-04 10:10:26 UTC
Permalink
Post by Hans-Peter Nilsson
Looks like you forgot to commit compress-debug.[ch]
Fixed.
--
Alan Modra
Australia Development Lab, IBM
H.J. Lu
2010-07-14 01:02:18 UTC
Permalink
Post by Cary Coutant
SEC_IN_MEMORY isn't sufficient.  Other sections will be SEC_IN_MEMORY
too, eg. SHT_GROUP sections.  I think your alternate approach of
twiddling the frag list is indicated.
Here's an updated patch that builds a new frag list. Since a frag
requires the data to follow the struct immediately, it didn't work
with the nice clean interface I added to bfd. It did lead to a more
efficient way of compressing, however: I now just stream each frag
through the compression engine, building new compressed frags as the
compressed data comes out, using the same obstack. At the end, I
replace the old frag list with the new one. I had to move the
zlib-specific code into a separate source file, because I can't
include as.h and zlib.h in the same file.
-cary
       * compress.c (bfd_uncompress_section_contents): Add ATTRIBUTE_UNUSED.
       * dwarf2.c (read_and_uncompress_section): New function.
       (read_section): Call it.
       (find_line): Likewise.
This change caused:

http://www.sourceware.org/bugzilla/show_bug.cgi?id=11817
--
H.J.
H.J. Lu
2010-07-09 19:51:25 UTC
Permalink
Post by Cary Coutant
A couple of years ago, Craig Silverstein submitted a patch to add
 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.
(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-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.
       * objdump.c (load_specific_debug_section): Decompress section contents
       before applying relocations.
       * readelf.c (load_specific_debug_section): Update section size after
       decompression.
       * 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.
Hi Cary,

I think it should be mentioned on gas/NEWS. Also you should add
the new options to "as --help".

Thanks.
--
H.J.
Cary Coutant
2010-07-12 22:30:53 UTC
Permalink
Post by H.J. Lu
I think it should be mentioned on gas/NEWS. Also you should add
the new options to "as --help".
How does this look?

-cary


* gas/NEWS: Add note about --compress-debug-sections.
* gas/as.c (show_usage): Add --compress-debug-sections and
--nocompress-debug-sections.


diff --git a/gas/NEWS b/gas/NEWS
index 1b7f9e9..db6b6d4 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -9,6 +9,11 @@

* Add support for the Renesas RX processor.

+* New command line option, --compress-debug-sections, which requests
+ compression of DWARF debug information sections in the relocatable output
+ file. Compressed debug sections are supported by readelf, objdump, and
+ gold, but not currently by Gnu ld.
+
Changes in 2.20:

* GNU/Linux targets now supports "gnu_unique_object" as a value in the .type
diff --git a/gas/as.c b/gas/as.c
index e494fa5..2457e8c 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -246,6 +246,10 @@ Options:\n\
fprintf (stream, _("\
--alternate initially turn on alternate macro syntax\n"));
fprintf (stream, _("\
+ --compress-debug-sections compress DWARF debug sections using zlib\n"));
+ fprintf (stream, _("\
+ --nocompress-debug-sections don't compress DWARF debug sections\n"));
+ fprintf (stream, _("\
-D produce assembler debugging messages\n"));
fprintf (stream, _("\
--debug-prefix-map OLD=NEW Map OLD to NEW in debug information\n"));
H.J. Lu
2010-07-12 22:41:43 UTC
Permalink
Post by Cary Coutant
Post by H.J. Lu
I think it should be mentioned on gas/NEWS. Also you should add
the new options to "as --help".
How does this look?
-cary
       * gas/NEWS: Add note about --compress-debug-sections.
       * gas/as.c (show_usage): Add --compress-debug-sections and
       --nocompress-debug-sections.
diff --git a/gas/NEWS b/gas/NEWS
index 1b7f9e9..db6b6d4 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -9,6 +9,11 @@
 * Add support for the Renesas RX processor.
+* New command line option, --compress-debug-sections, which requests
+  compression of DWARF debug information sections in the relocatable output
+  file.  Compressed debug sections are supported by readelf, objdump, and
+  gold, but not currently by Gnu ld.
+
 * GNU/Linux targets now supports "gnu_unique_object" as a value in the .type
diff --git a/gas/as.c b/gas/as.c
index e494fa5..2457e8c 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -246,6 +246,10 @@ Options:\n\
  fprintf (stream, _("\
  --alternate             initially turn on alternate macro syntax\n"));
  fprintf (stream, _("\
+  --compress-debug-sections  compress DWARF debug sections using zlib\n"));
+  fprintf (stream, _("\
+  --nocompress-debug-sections  don't compress DWARF debug sections\n"));
+  fprintf (stream, _("\
  -D                      produce assembler debugging messages\n"));
  fprintf (stream, _("\
  --debug-prefix-map OLD=NEW  Map OLD to NEW in debug information\n"));
It looks OK to me, except we should align the explanation text. But I
can't approve it.

Thanks.
--
H.J.
Cary Coutant
2010-07-12 22:57:05 UTC
Permalink
It looks OK to me, except we should align the explanation text.  But I
can't approve it.
OK, I can start the explanation text on the next line, like
--reduce-memory-overheads (but unlike --debug-prefix-map). Should I
fix --debug-prefix-map while I'm there?

-cary
H.J. Lu
2010-07-12 23:02:29 UTC
Permalink
Post by Cary Coutant
It looks OK to me, except we should align the explanation text.  But I
can't approve it.
OK, I can start the explanation text on the next line, like
--reduce-memory-overheads (but unlike --debug-prefix-map). Should I
fix --debug-prefix-map while I'm there?
Yes, that will be great.

Thanks.
--
H.J.
Cary Coutant
2010-07-12 23:34:26 UTC
Permalink
Post by H.J. Lu
Post by Cary Coutant
OK, I can start the explanation text on the next line, like
--reduce-memory-overheads (but unlike --debug-prefix-map). Should I
fix --debug-prefix-map while I'm there?
Yes, that will be great.
OK, here's an updated patch...

-cary


gas/ChangeLog:

* NEWS: Add note about --compress-debug-sections.
* as.c (show_usage): Add --compress-debug-sections and
--nocompress-debug-sections.


diff --git a/gas/NEWS b/gas/NEWS
index 1b7f9e9..db6b6d4 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -9,6 +9,11 @@

* Add support for the Renesas RX processor.

+* New command line option, --compress-debug-sections, which requests
+ compression of DWARF debug information sections in the relocatable output
+ file. Compressed debug sections are supported by readelf, objdump, and
+ gold, but not currently by Gnu ld.
+
Changes in 2.20:

* GNU/Linux targets now supports "gnu_unique_object" as a value in the .type
diff --git a/gas/as.c b/gas/as.c
index e494fa5..45acbaa 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -246,9 +246,16 @@ Options:\n\
fprintf (stream, _("\
--alternate initially turn on alternate macro syntax\n"));
fprintf (stream, _("\
+ --compress-debug-sections\n\
+ compress DWARF debug sections using zlib\n"));
+ fprintf (stream, _("\
+ --nocompress-debug-sections\n\
+ don't compress DWARF debug sections\n"));
+ fprintf (stream, _("\
-D produce assembler debugging messages\n"));
fprintf (stream, _("\
- --debug-prefix-map OLD=NEW Map OLD to NEW in debug information\n"));
+ --debug-prefix-map OLD=NEW\n\
+ map OLD to NEW in debug information\n"));
fprintf (stream, _("\
--defsym SYM=VAL define symbol SYM to given value\n"));
#ifdef USE_EMULATIONS
Alan Modra
2010-07-15 04:50:42 UTC
Permalink
Post by Cary Coutant
* NEWS: Add note about --compress-debug-sections.
* as.c (show_usage): Add --compress-debug-sections and
--nocompress-debug-sections.
OK.
--
Alan Modra
Australia Development Lab, IBM
H.J. Lu
2010-07-20 21:40:33 UTC
Permalink
Post by Cary Coutant
Post by H.J. Lu
I think it should be mentioned on gas/NEWS. Also you should add
the new options to "as --help".
How does this look?
-cary
       * gas/NEWS: Add note about --compress-debug-sections.
       * gas/as.c (show_usage): Add --compress-debug-sections and
       --nocompress-debug-sections.
Hi Cary,

Sorry for not noticing it before. Did you update assembler document?
--
H.J.
Cary Coutant
2010-07-20 23:31:53 UTC
Permalink
Post by H.J. Lu
Post by Cary Coutant
       * gas/NEWS: Add note about --compress-debug-sections.
       * gas/as.c (show_usage): Add --compress-debug-sections and
       --nocompress-debug-sections.
Sorry for not noticing it before. Did you update assembler document?
No -- you mean doc/as.texinfo, right? Should the new options just go
into the main list of options, in alphabetical order?

-cary
H.J. Lu
2010-07-21 13:07:35 UTC
Permalink
Post by Cary Coutant
Post by H.J. Lu
Post by Cary Coutant
       * gas/NEWS: Add note about --compress-debug-sections.
       * gas/as.c (show_usage): Add --compress-debug-sections and
       --nocompress-debug-sections.
Sorry for not noticing it before. Did you update assembler document?
No -- you mean doc/as.texinfo, right? Should the new options just go
into the main list of options, in alphabetical order?
I think alphabetical order should work.

Thanks.
--
H.J.
Cary Coutant
2010-08-03 20:47:26 UTC
Permalink
Post by H.J. Lu
Post by Cary Coutant
Post by H.J. Lu
Sorry for not noticing it before. Did you update assembler document?
No -- you mean doc/as.texinfo, right? Should the new options just go
into the main list of options, in alphabetical order?
I think alphabetical order should work.
I forgot about this until Nick reminded me. How's this?

Sorry for the delay.

-cary


* doc/as.texinfo: Add --compress-debug-sections,
--nocompress-debug-sections.


diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index a8327b8..f17c591 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -232,6 +232,7 @@ gcc(1), ld(1), and the Info entries for
@file{binutils} and @file{ld}.
@smallexample
@c man begin SYNOPSIS
@value{AS} [@b{-a}[@b{cdghlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
+ [@b{--compress-debug-sections}] [@b{--nocompress-debug-sections}]
[@b{--debug-prefix-map} @var{old}=@var{new}]
[@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}]
[@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}]
@@ -552,6 +553,14 @@ Begin in alternate macro mode.
@xref{Altmacro,,@code{.altmacro}}.
@end ifclear

+@item --compress-debug-sections
+Compress DWARF debug sections using zlib. The debug sections are renamed
+to begin with @samp{.zdebug}, and the resulting object file may not be
+compatible with older linkers and object file utilities.
+
+@item --nocompress-debug-sections
+Do not compress DWARF debug sections. This is the default.
+
@item -D
Ignored. This option is accepted for script compatibility with calls to
other assemblers.
Nick Clifton
2010-08-04 12:44:28 UTC
Permalink
Hi Cary,
Post by Cary Coutant
I forgot about this until Nick reminded me. How's this?
OK - except for one small detail...
Post by Cary Coutant
+Compress DWARF debug sections using zlib. The debug sections are renamed
+compatible with older linkers and object file utilities.
I think that you should mention that this feature is only available if
the zlib library is available on the host machine.

Cheers
Nick
Cary Coutant
2010-08-04 18:36:06 UTC
Permalink
+Compress DWARF debug sections using zlib.  The debug sections are renamed
+compatible with older linkers and object file utilities.
I think that you should mention that this feature is only available if the
zlib library is available on the host machine.
More specifically, if it was available when gas was configured and
built, right? How should I phrase that? Or would the following be
sufficient?

"... If the zlib library is not available on the host machine, this
option has no effect."

-cary
H.J. Lu
2010-08-04 18:38:25 UTC
Permalink
Post by Cary Coutant
+Compress DWARF debug sections using zlib.  The debug sections are renamed
+compatible with older linkers and object file utilities.
I think that you should mention that this feature is only available if the
zlib library is available on the host machine.
More specifically, if it was available when gas was configured and
built, right? How should I phrase that? Or would the following be
sufficient?
"... If the zlib library is not available on the host machine, this
option has no effect."
zlib is in gcc source tree. Can we include it in binutils?
--
H.J.
Nick Clifton
2010-08-05 10:28:52 UTC
Permalink
Hi Cary,
Post by Cary Coutant
More specifically, if it was available when gas was configured and
built, right?
Right.
Post by Cary Coutant
How should I phrase that? Or would the following be
sufficient?
"... If the zlib library is not available on the host machine, this
option has no effect."
Actually just looking at the code in write.c, is there actually any
check for the absence of the zlibrary ? Ie can the sources currently be
compiled on a system with zlib installed ?

Also, if zlib is not installed, then it would be fairer to the user if
the --compress-debug-section was not mentioned in the --help output, and
produced a warning if used. Otherwise someone could add
--compress-debug-sections to their command line and then wonder why they
are not getting any smaller binaries.

Cheers
Nick
Tristan Gingold
2010-08-05 10:33:28 UTC
Permalink
Actually just looking at the code in write.c, is there actually any check for the absence of the zlibrary ? Ie can the sources currently be compiled on a system with zlib installed ?
with zlib *not* installed ? Yes, this is handled in compress-debug.c and yes I have tested that on vms :-)
Also, if zlib is not installed, then it would be fairer to the user if the --compress-debug-section was not mentioned in the --help output, and produced a warning if used. Otherwise someone could add --compress-debug-sections to their command line and then wonder why they are not getting any smaller binaries.
Indeed.

Tristan.
Cary Coutant
2010-08-05 18:49:28 UTC
Permalink
Actually just looking at the code in write.c, is there actually any check
for the absence of the zlibrary ?  Ie can the sources currently be compiled
on a system with zlib installed ?
Yes, the compression routines in compress-debug.c reduce to empty
stubs if zlib is not installed.
Also, if zlib is not installed, then it would be fairer to the user if the
--compress-debug-section was not mentioned in the --help output, and
produced a warning if used.  Otherwise someone could add
--compress-debug-sections to their command line and then wonder why they are
not getting any smaller binaries.
Sounds better. Here's a revised patch.

-cary


* as.c (show_usage): Don't list --compress-debug-sections if zlib not
installed.
(main): Warn if --compress-debug-sections requested and zlib not
installed.
* doc/as.texinfo: Add --compress-debug-sections,
--nocompress-debug-sections.


diff --git a/gas/as.c b/gas/as.c
index 45acbaa..d9aa6e2 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -245,12 +245,14 @@ Options:\n\

fprintf (stream, _("\
--alternate initially turn on alternate macro syntax\n"));
+#ifdef HAVE_ZLIB_H
fprintf (stream, _("\
--compress-debug-sections\n\
compress DWARF debug sections using zlib\n"));
fprintf (stream, _("\
--nocompress-debug-sections\n\
don't compress DWARF debug sections\n"));
+#endif /* HAVE_ZLIB_H */
fprintf (stream, _("\
-D produce assembler debugging messages\n"));
fprintf (stream, _("\
@@ -646,7 +648,11 @@ This program has absolutely no warranty.\n"));
exit (EXIT_SUCCESS);

case OPTION_COMPRESS_DEBUG:
+#ifdef HAVE_ZLIB_H
flag_compress_debug = 1;
+#else
+ as_warn (_("cannot compress debug sections (zlib not installed)"));
+#endif /* HAVE_ZLIB_H */
break;

case OPTION_NOCOMPRESS_DEBUG:
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index a8327b8..f17c591 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -232,6 +232,7 @@ gcc(1), ld(1), and the Info entries for
@file{binutils} and @file{ld}.
@smallexample
@c man begin SYNOPSIS
@value{AS} [@b{-a}[@b{cdghlns}][=@var{file}]] [@b{--alternate}] [@b{-D}]
+ [@b{--compress-debug-sections}] [@b{--nocompress-debug-sections}]
[@b{--debug-prefix-map} @var{old}=@var{new}]
[@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}]
[@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--help}] [@b{-I} @var{dir}] [@b{-J}]
@@ -552,6 +553,14 @@ Begin in alternate macro mode.
@xref{Altmacro,,@code{.altmacro}}.
@end ifclear

+@item --compress-debug-sections
+Compress DWARF debug sections using zlib. The debug sections are renamed
+to begin with @samp{.zdebug}, and the resulting object file may not be
+compatible with older linkers and object file utilities.
+
+@item --nocompress-debug-sections
+Do not compress DWARF debug sections. This is the default.
+
@item -D
Ignored. This option is accepted for script compatibility with calls to
other assemblers.
Nick Clifton
2010-08-06 08:54:20 UTC
Permalink
Hi Cary,
Post by Cary Coutant
* as.c (show_usage): Don't list --compress-debug-sections if zlib not
installed.
(main): Warn if --compress-debug-sections requested and zlib not
installed.
* doc/as.texinfo: Add --compress-debug-sections,
--nocompress-debug-sections.
Good, although the documentation still does not mention that
--compress-debug-sections may not be supported. How about:

@item --compress-debug-sections
Compress DWARF debug sections using zlib. The debug sections are renamed
to begin with @samp{.zdebug}, and the resulting object file may not be
compatible with older linkers and object file utilities. This option is
only supported if the host machine has the zlib compression library.

Cheers
Nick
H.J. Lu
2010-08-06 13:42:47 UTC
Permalink
Post by H.J. Lu
Hi Cary,
        * as.c (show_usage): Don't list --compress-debug-sections if zlib
not
        installed.
        (main): Warn if --compress-debug-sections requested and zlib not
        installed.
        * doc/as.texinfo: Add --compress-debug-sections,
        --nocompress-debug-sections.
Good, although the documentation still does not mention that
 Compress DWARF debug sections using zlib.  The debug sections are renamed
 compatible with older linkers and object file utilities.  This option is
 only supported if the host machine has the zlib compression library.
The object files with compressed debug sections aren't compatible
with any binutils programs, except for gold:

http://sourceware.org/bugzilla/show_bug.cgi?id=11819
--
H.J.
Cary Coutant
2010-08-06 17:28:08 UTC
Permalink
Post by H.J. Lu
The object files with compressed debug sections aren't compatible
http://sourceware.org/bugzilla/show_bug.cgi?id=11819
I'm hoping that your patch will be approved soon to fix that.

Nick, is there any reason not to approve HJ's patch?

http://sourceware.org/ml/binutils/2010-07/msg00351.html

The objection raised to that patch was more an issue with the original
patch that adds the --compress-debug-sections option to gas, not with
HJ's patch to make the rest of binutils support the files that gas
produces.

-cary
Cary Coutant
2010-08-06 17:21:27 UTC
Permalink
Post by Nick Clifton
Good, although the documentation still does not mention that
 Compress DWARF debug sections using zlib.  The debug sections are renamed
 compatible with older linkers and object file utilities.  This option is
 only supported if the host machine has the zlib compression library.
Sorry, I forgot to incorporate that change into my patch. Is this
patch OK to apply with your suggested change?

-cary
Nick Clifton
2010-08-09 07:30:41 UTC
Permalink
Hi Cary,
Post by Cary Coutant
Post by Cary Coutant
@item --compress-debug-sections
Compress DWARF debug sections using zlib. The debug sections are renamed
compatible with older linkers and object file utilities. This option is
only supported if the host machine has the zlib compression library.
Sorry, I forgot to incorporate that change into my patch. Is this
patch OK to apply with your suggested change?
Yes - please apply.

Cheers
Nick
Cary Coutant
2010-08-09 18:08:57 UTC
Permalink
Post by Nick Clifton
Post by Cary Coutant
Post by H.J. Lu
 Compress DWARF debug sections using zlib.  The debug sections are renamed
 compatible with older linkers and object file utilities.  This option is
 only supported if the host machine has the zlib compression library.
Sorry, I forgot to incorporate that change into my patch. Is this
patch OK to apply with your suggested change?
Yes - please apply.
Thanks! Applied.

-cary

Loading...