diff mbox

[debug] dwarf2out emits unnecessary null byte in empty .debug_abbrev section

Message ID 1300983995.4889.62.camel@springer.wildebeest.org
State New
Headers show

Commit Message

Mark Wielaard March 24, 2011, 4:26 p.m. UTC
Hi,

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.

2011-03-24  Mark Wielaard  <mjw@redhat.com>

    PR debug/48041
    * dwarf2out.c (output_abbrev_section): Only terminate table when
    abbrev_die_table_in_use > 1.

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

OK, to commit?

Thanks,

Mark

Comments

Richard Henderson March 24, 2011, 8:14 p.m. UTC | #1
On 03/24/2011 09:26 AM, Mark Wielaard wrote:
>    /* Terminate the table.  */
> -  dw2_asm_output_data (1, 0, NULL);
> +  if (abbrev_die_table_in_use > 1)
> +    dw2_asm_output_data (1, 0, NULL);

I'd prefer this to be handled by 

  if (abbrev_die_table_in_use == 0)
    return;

at the beginning of the function.

Ok with that change.


r~
diff mbox

Patch

--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11084,7 +11084,8 @@  output_abbrev_section (void)
     }
 
   /* 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.  */