Bug 48041 - dwarf2out emits unnecessary null byte in empty .debug_abbrev section
Summary: dwarf2out emits unnecessary null byte in empty .debug_abbrev section
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 4.7.1
Assignee: Mark Wielaard
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-09 09:55 UTC by Mark Wielaard
Modified: 2012-03-22 09:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-06-29 10:20:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Wielaard 2011-03-09 09:55:51 UTC
Detected by the elfutils dwarflint tool.

Example:
$ echo > empty.c 
$ gcc -g -c empty.c 
$ readelf -x .debug_abbrev empty.o
Hex dump of section '.debug_abbrev':
  0x00000000 00                                  .

Although harmless it might add up if a project has a lot of objects without any real debuginfo in them. There might not actually be many such projects though.

The fix seems easy:

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 170813)
+++ gcc/dwarf2out.c	(working copy)
@@ -11058,7 +11058,8 @@
     }
 
   /* Terminate the table.  */
-  dw2_asm_output_data (1, 0, NULL);
+  if (abbrev_die_table_in_use > 1)
+    dw2_asm_output_data (1, 0, NULL);
 }
 
 /* Output a symbol we can use to refer to this DIE from another CU.  */

Bootstraps fine on x86_64-gnu-linux and no regressions seen with make check -k

I'll submit it to gcc-patches when the tree opens up again for stage one.
Comment 1 Mark Wielaard 2011-03-25 09:35:44 UTC
Author: mark
Date: Fri Mar 25 09:35:41 2011
New Revision: 171441

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171441
Log:
PR debug/48041
* dwarf2out.c (output_abbrev_section): Only write table when
abbrev_die_table_in_use > 1.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
Comment 2 Mark Wielaard 2011-03-28 09:10:09 UTC
Patch committed.
Comment 3 Rainer Orth 2011-06-29 10:20:52 UTC
Unfortunately, this caused PR debug/49364.  I think the patch should be reverted
or the .debug_abbrev section not be emitted at all in this case.
Comment 4 Richard Biener 2012-03-22 08:26:21 UTC
GCC 4.7.0 is being released, adjusting target milestone.
Comment 5 Mark Wielaard 2012-03-22 09:22:50 UTC
The regression against the mips-sgi-irix vendor tools noted in comment #3 was fixed in PR debug/49364 through http://gcc.gnu.org/viewcvs?view=revision&revision=175694