Bug 12409 - --compress-debug-sections doesn't work on empty DWARF sections
Summary: --compress-debug-sections doesn't work on empty DWARF sections
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-18 18:26 UTC by H.J. Lu
Modified: 2011-01-18 18:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-01-18 18:26:18 UTC
Gcc may generate assembly codes with empty DWARF sections.
--compress-debug-sections failed on them:

[hjl@gnu-6 compress-4]$ cat x.s
	.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
[hjl@gnu-6 compress-4]$ make
./as --compress-debug-sections -o compressed.o x.s
objcopy --decompress-debug-sections compressed.o decompressed.o
./as --nocompress-debug-sections -o x.o x.s
readelf -w x.o
Contents of the .debug_abbrev section:



Section '.debug_info' has no debugging data.

Section '.debug_line' has no debugging data.
readelf -w decompressed.o
Contents of the .debug_abbrev section:


readelf: Warning: Corrupt unit length (0) found in section .zdebug_info
Raw dump of debug contents of section .zdebug_line:

readelf: Warning: Only DWARF version 2, 3 and 4 line info is currently supported.
cmp decompressed.o x.o
decompressed.o x.o differ: byte 41, line 1
make: *** [all] Error 1
[hjl@gnu-6 compress-4]$
Comment 1 cvs-commit@gcc.gnu.org 2011-01-18 18:56:02 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-01-18 18:55:59

Modified files:
	gas            : ChangeLog write.c 
	gas/testsuite  : ChangeLog 
	gas/testsuite/gas/elf: elf.exp 
Added files:
	gas/testsuite/gas/elf: dwarf2-4.d dwarf2-4.s 

Log message:
	Don't compress empty debug sections.
	
	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.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4391&r2=1.4392
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/write.c.diff?cvsroot=src&r1=1.137&r2=1.138
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1841&r2=1.1842
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/dwarf2-4.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/dwarf2-4.s.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/elf.exp.diff?cvsroot=src&r1=1.72&r2=1.73
Comment 2 H.J. Lu 2011-01-18 18:58:08 UTC
Fixed.