public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
@ 2011-01-18 18:57 H.J. Lu
  2011-01-18 23:54 ` H.J. Lu
  2011-02-10  5:06 ` Alan Modra
  0 siblings, 2 replies; 7+ messages in thread
From: H.J. Lu @ 2011-01-18 18:57 UTC (permalink / raw)
  To: binutils; +Cc: Cary Coutant

Hi,

We shouldn't compress empty DWARF sections.  I checked in this patch as
an obvious fix.


H.J.
---
gas/

2011-01-18  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/12409
	* write.c (compress_debug): Return if section size is 0.

gas/testsuite/

2011-01-18  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/12409
	* gas/elf/dwarf2-4.d: New.
	* gas/elf/dwarf2-4.s: Likewise.

diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 7f86266..3828151 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -178,5 +178,6 @@ if { ([istarget "*-*-*elf*"]
     run_dump_test "dwarf2-1"
     run_dump_test "dwarf2-2"
     run_dump_test "dwarf2-3"
+    run_dump_test "dwarf2-4"
     run_dump_test "bad-section-flag"
 }
diff --git a/gas/write.c b/gas/write.c
index 018800e..aabb96d 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1359,6 +1359,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
   flagword flags = bfd_get_section_flags (abfd, sec);
 
   if (seginfo == NULL
+      || sec->size == 0
       || (flags & (SEC_ALLOC | SEC_HAS_CONTENTS)) == SEC_ALLOC)
     return;
 
--- /dev/null	2011-01-10 09:06:52.507000001 -0800
+++ binutils/gas/testsuite/gas/elf/dwarf2-4.d	2011-01-18 10:45:40.219381036 -0800
@@ -0,0 +1,12 @@
+#as:  --compress-debug-sections
+#readelf: -w
+#name: DWARF2 4
+#not-target: ia64-*-*
+
+Contents of the .[z]?debug_abbrev section:
+
+
+
+Section '.debug_info' has no debugging data.
+
+Section '.debug_line' has no debugging data.
--- /dev/null	2011-01-10 09:06:52.507000001 -0800
+++ binutils/gas/testsuite/gas/elf/dwarf2-4.s	2011-01-18 10:43:23.829263858 -0800
@@ -0,0 +1,12 @@
+	.file	"__dn_comp.c"
+	.section	.debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+	.section	.debug_info,"",@progbits
+.Ldebug_info0:
+	.section	.debug_line,"",@progbits
+.Ldebug_line0:
+	.text
+.Ltext0:
+.Letext0:
+	.section	.debug_abbrev
+	.byte	0x0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
  2011-01-18 18:57 PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections H.J. Lu
@ 2011-01-18 23:54 ` H.J. Lu
  2011-01-19  0:00   ` Cary Coutant
  2011-01-19  0:09   ` Alan Modra
  2011-02-10  5:06 ` Alan Modra
  1 sibling, 2 replies; 7+ messages in thread
From: H.J. Lu @ 2011-01-18 23:54 UTC (permalink / raw)
  To: Cary Coutant; +Cc: binutils

On Tue, Jan 18, 2011 at 10:57 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> We shouldn't compress empty DWARF sections.  I checked in this patch as
> an obvious fix.
>
>
> H.J.
> ---
> gas/
>
> 2011-01-18  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR gas/12409
>        * write.c (compress_debug): Return if section size is 0.
>


Should I apply this patch? Since the compression header is 12 byte,
if the section is smaller than 12 bytes, compressed section will be
bigger.

H.J.
---
diff --git a/gas/write.c b/gas/write.c
index aabb96d..9e4d6f4 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1359,7 +1359,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIB
UTE_UNUSED)
   flagword flags = bfd_get_section_flags (abfd, sec);

   if (seginfo == NULL
-      || sec->size == 0
+      || sec->size < 12
       || (flags & (SEC_ALLOC | SEC_HAS_CONTENTS)) == SEC_ALLOC)
     return;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
  2011-01-18 23:54 ` H.J. Lu
@ 2011-01-19  0:00   ` Cary Coutant
  2011-01-19  0:09   ` Alan Modra
  1 sibling, 0 replies; 7+ messages in thread
From: Cary Coutant @ 2011-01-19  0:00 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

> Should I apply this patch? Since the compression header is 12 byte,
> if the section is smaller than 12 bytes, compressed section will be
> bigger.

It's fine with me. You may also want to check whether the compressed
bits actually come out smaller than the uncompressed bits. The test
you've added here is just a trivial case of the more general one.

The reason I didn't do this originally was so that we wouldn't end up
with a mixture of compressed and uncompressed sections in one file,
for fear of what effect that might have on downstream tools. With the
bfd and linker changes we have, I think this is safe now.

-cary

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
  2011-01-18 23:54 ` H.J. Lu
  2011-01-19  0:00   ` Cary Coutant
@ 2011-01-19  0:09   ` Alan Modra
  2011-01-19  0:13     ` H.J. Lu
  1 sibling, 1 reply; 7+ messages in thread
From: Alan Modra @ 2011-01-19  0:09 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Cary Coutant, binutils

On Tue, Jan 18, 2011 at 03:54:32PM -0800, H.J. Lu wrote:
> Should I apply this patch? Since the compression header is 12 byte,
> if the section is smaller than 12 bytes, compressed section will be
> bigger.

OK.  Perhaps a larger value would be even better?

> diff --git a/gas/write.c b/gas/write.c
> index aabb96d..9e4d6f4 100644
> --- a/gas/write.c
> +++ b/gas/write.c
> @@ -1359,7 +1359,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIB
> UTE_UNUSED)
>    flagword flags = bfd_get_section_flags (abfd, sec);
> 
>    if (seginfo == NULL
> -      || sec->size == 0
> +      || sec->size < 12
>        || (flags & (SEC_ALLOC | SEC_HAS_CONTENTS)) == SEC_ALLOC)
>      return;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
  2011-01-19  0:09   ` Alan Modra
@ 2011-01-19  0:13     ` H.J. Lu
  2011-01-19  0:22       ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2011-01-19  0:13 UTC (permalink / raw)
  To: Cary Coutant, binutils

On Tue, Jan 18, 2011 at 4:08 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Jan 18, 2011 at 03:54:32PM -0800, H.J. Lu wrote:
>> Should I apply this patch? Since the compression header is 12 byte,
>> if the section is smaller than 12 bytes, compressed section will be
>> bigger.
>
> OK.  Perhaps a larger value would be even better?
>
>> diff --git a/gas/write.c b/gas/write.c
>> index aabb96d..9e4d6f4 100644
>> --- a/gas/write.c
>> +++ b/gas/write.c
>> @@ -1359,7 +1359,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIB
>> UTE_UNUSED)
>>    flagword flags = bfd_get_section_flags (abfd, sec);
>>
>>    if (seginfo == NULL
>> -      || sec->size == 0
>> +      || sec->size < 12
>>        || (flags & (SEC_ALLOC | SEC_HAS_CONTENTS)) == SEC_ALLOC)
>>      return;
>

How about 64?


-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
  2011-01-19  0:13     ` H.J. Lu
@ 2011-01-19  0:22       ` H.J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2011-01-19  0:22 UTC (permalink / raw)
  To: Cary Coutant, binutils

On Tue, Jan 18, 2011 at 4:13 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jan 18, 2011 at 4:08 PM, Alan Modra <amodra@gmail.com> wrote:
>> On Tue, Jan 18, 2011 at 03:54:32PM -0800, H.J. Lu wrote:
>>> Should I apply this patch? Since the compression header is 12 byte,
>>> if the section is smaller than 12 bytes, compressed section will be
>>> bigger.
>>
>> OK.  Perhaps a larger value would be even better?
>>
>>> diff --git a/gas/write.c b/gas/write.c
>>> index aabb96d..9e4d6f4 100644
>>> --- a/gas/write.c
>>> +++ b/gas/write.c
>>> @@ -1359,7 +1359,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIB
>>> UTE_UNUSED)
>>>    flagword flags = bfd_get_section_flags (abfd, sec);
>>>
>>>    if (seginfo == NULL
>>> -      || sec->size == 0
>>> +      || sec->size < 12
>>>        || (flags & (SEC_ALLOC | SEC_HAS_CONTENTS)) == SEC_ALLOC)
>>>      return;
>>
>
> How about 64?
>

I will use 32.

-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections
  2011-01-18 18:57 PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections H.J. Lu
  2011-01-18 23:54 ` H.J. Lu
@ 2011-02-10  5:06 ` Alan Modra
  1 sibling, 0 replies; 7+ messages in thread
From: Alan Modra @ 2011-02-10  5:06 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On Tue, Jan 18, 2011 at 10:57:33AM -0800, H.J. Lu wrote:
> We shouldn't compress empty DWARF sections.  I checked in this patch as
> an obvious fix.
[snip]
> 	PR gas/12409
> 	* gas/elf/dwarf2-4.d: New.
> 	* gas/elf/dwarf2-4.s: Likewise.

Breaks on arm.

	* gas/elf/dwarf2-4.s: Don't use @.

Index: gas/testsuite/gas/elf/dwarf2-4.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/elf/dwarf2-4.s,v
retrieving revision 1.1
diff -u -p -r1.1 dwarf2-4.s
--- gas/testsuite/gas/elf/dwarf2-4.s	18 Jan 2011 18:55:59 -0000	1.1
+++ gas/testsuite/gas/elf/dwarf2-4.s	10 Feb 2011 04:00:02 -0000
@@ -1,9 +1,9 @@
 	.file	"__dn_comp.c"
-	.section	.debug_abbrev,"",@progbits
+	.section	.debug_abbrev,"",%progbits
 .Ldebug_abbrev0:
-	.section	.debug_info,"",@progbits
+	.section	.debug_info,"",%progbits
 .Ldebug_info0:
-	.section	.debug_line,"",@progbits
+	.section	.debug_line,"",%progbits
 .Ldebug_line0:
 	.text
 .Ltext0:


-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-10  5:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 18:57 PATCH: PR gas/12409: --compress-debug-sections doesn't work on empty DWARF sections H.J. Lu
2011-01-18 23:54 ` H.J. Lu
2011-01-19  0:00   ` Cary Coutant
2011-01-19  0:09   ` Alan Modra
2011-01-19  0:13     ` H.J. Lu
2011-01-19  0:22       ` H.J. Lu
2011-02-10  5:06 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).