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]

Re: [committed, PATCH] Don't write the zlib header if not used


On Tue, Mar 24, 2015 at 7:08 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Mar 24, 2015 at 1:30 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> No need to write the zlib header if compression didn't make the section
>> smaller.  I checked this into master.
>>
>>
>> H.J.
>> ---
>>         PR binutils/18087
>>         * compress.c (bfd_compress_section_contents): Don't write the
>>         zlib header and set contents as well as compress_status if
>>         compression didn't make the section smaller.
>>         (bfd_init_section_compress_status): Don't check compression
>>         size here.
>> ---
>>  bfd/ChangeLog  |  9 +++++++++
>>  bfd/compress.c | 56 ++++++++++++++++++++++++++------------------------------
>>  2 files changed, 35 insertions(+), 30 deletions(-)
>>
>> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
>> index 73c155c..469066b 100644
>> --- a/bfd/ChangeLog
>> +++ b/bfd/ChangeLog
>> @@ -1,3 +1,12 @@
>> +2015-03-24  H.J. Lu  <hongjiu.lu@intel.com>
>> +
>> +       PR gas/18087
>> +       * compress.c (bfd_compress_section_contents): Don't write the
>> +       zlib header and set contents as well as compress_status if
>> +       compression didn't make the section smaller.
>> +       (bfd_init_section_compress_status): Don't check compression
>> +       size here.
>> +
>
> I also committed a similar patch for gas.
>

We should xfail the compressed debug section test if there are
no compressed sections.  Committed.

-- 
H.J.
From 317974f6831d8c7af613257e190e0dc3125bc4cf Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 5 Apr 2015 08:11:11 -0700
Subject: [PATCH] Xfail the compressed debug sections

There is no need to generate compressed debug section if compressed
section size is the same as before compression.  We should xfail the
compressed debug section test if there are no compressed sections

binutils/testsuite/

	* binutils-all/compress.exp (compression_used): New.
	Xfail test if compression didn't make the section smaller.

gas/

2015-04-05  H.J. Lu  <hongjiu.lu@intel.com>

	* write.c (compress_debug): Don't write the zlib header if
	compressed section size is the same as before compression.
---
 binutils/testsuite/ChangeLog                 |  5 +++++
 binutils/testsuite/binutils-all/compress.exp | 12 ++++++++++++
 gas/ChangeLog                                |  5 +++++
 gas/write.c                                  |  2 +-
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog
index 827e836..ff77d51 100644
--- a/binutils/testsuite/ChangeLog
+++ b/binutils/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* binutils-all/compress.exp (compression_used): New.
+	Xfail test if compression didn't make the section smaller.
+
 2015-04-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* binutils-all/compress.exp (testfile): Remove suffix.
diff --git a/binutils/testsuite/binutils-all/compress.exp b/binutils/testsuite/binutils-all/compress.exp
index 02111f1..f170aea 100644
--- a/binutils/testsuite/binutils-all/compress.exp
+++ b/binutils/testsuite/binutils-all/compress.exp
@@ -39,6 +39,15 @@ if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --com
     return
 }
 
+set got [remote_exec host "cmp ${testfile}.o ${compressedfile}.o" "" "/dev/null"]
+# Use it to set up xfail.
+set exec_output [lindex $got 1]
+if [string match "" $exec_output] then {
+    set compression_used ""
+} else {
+    set compression_used "yes"
+}
+
 if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}.o --compress-debug-sections] } then {
     unsupported "compressed debug sections"
     return
@@ -125,6 +134,8 @@ if ![string match "" $got] then {
     }
 }
 
+# Xfail this test if there are no compressed sections.
+setup_xfail "$compression_used$target_triplet"
 set testname "objcopy compress debug sections in archive"
 set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
 if ![string match "" $got] then {
@@ -138,6 +149,7 @@ if ![string match "" $got] then {
 	send_log "\n"
     }
 
+    setup_xfail "$compression_used$target_triplet"
     if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
 	fail "$testname"
     } else {
diff --git a/gas/ChangeLog b/gas/ChangeLog
index a2383a9..f2a1bf2 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* write.c (compress_debug): Don't write the zlib header if
+	compressed section size is the same as before compression.
+
 2015-04-02  Nick Clifton  <nickc@redhat.com>
 
 	PR gas/18189
diff --git a/gas/write.c b/gas/write.c
index 6a781ea..248255b 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1519,7 +1519,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
 
   /* PR binutils/18087: If compression didn't make the section smaller,
      just keep it uncompressed.  */
-  if (compressed_size > uncompressed_size)
+  if (compressed_size >= uncompressed_size)
     return;
 
   memcpy (header, "ZLIB", 4);
-- 
2.1.0


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