Found using the elfutils dwarflint tool. Example: $ echo "static int empty;" > empty.c $ gcc -g -c empty.c $ readelf --debug-dump=info empty.o | grep DW_AT_stmt <29> DW_AT_stmt_list : 0x0 $ readelf --debug-dump=decodedline empty.o Decoded dump of debug contents of section .debug_line: CU: empty.c: File name Line number Starting address It seems wrong to output a DW_AT_stmt_list if there are no statements at all. Possible patch: Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 170813) +++ gcc/dwarf2out.c (working copy) @@ -23485,7 +23486,7 @@ add_ranges (NULL); } - if (debug_info_level >= DINFO_LEVEL_NORMAL) + if (debug_info_level >= DINFO_LEVEL_NORMAL && line_info_table_in_use > 1) add_AT_lineptr (comp_unit_die (), DW_AT_stmt_list, debug_line_section_label); @@ -23512,7 +23513,7 @@ /* Add a pointer to the line table for the main compilation unit so that the debugger can make sense of DW_AT_decl_file attributes. */ - if (debug_info_level >= DINFO_LEVEL_NORMAL) + if (debug_info_level >= DINFO_LEVEL_NORMAL && line_info_table_in_use > 1) add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list, debug_line_section_label);
The previous patch is wrong, it should depend on either a .loc or a .line output. I had misunderstood when the DW_AT_stmt_list was really necessary. Also there was some debate on whether or not pointing to an empty line number table was actually wrong. We might want to change dwarflint to just allow it. See the discussion here: https://fedorahosted.org/pipermail/elfutils-devel/2011-March/001840.html