Hi! Eric changed dwarf2out_finish in January to fix PR46704, unfortunately that change means we often don't emit .debug_aranges at all even when it should be present and is needed for e.g. elfutils. In PR46704 there were 2 DECL_IGNORED functions with -O2 -g -fkeep-inline-functions, so fde_table_in_use was 2, but .debug_info section wasn't emitted as it was empty and thus .debug_aranges referenced non-existent .Ldebug_info0 symbol. arange_table_in_use is often 0, in particular if all emitted functions are only in .text/.text.unlikely sections. .debug_aranges contains first range of .text the current CU covers, then range of .text.unlikely and only afterwards the other ranges (arange_table_in_use is count of those).
The following patch fixes it by emitting .debug_aranges whenever it will be non-empty (and the extra && info_section_emitted is just to make sure .Ldebug_info0 can be used too). If you want, for 4.7+ I think we could just use if (text_section_used || cold_text_section_used || arange_table_in_use) { gcc_assert (info_section_emitted); ... Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.6? 2011-03-18 Jakub Jelinek <ja...@redhat.com> PR debug/48176 * dwarf2out.c (dwarf2out_finish): Call output_aranges even when arange_table_in_use is 0, but either text_section_used or cold_text_section_used is true. Don't call it if !info_section_emitted. --- gcc/dwarf2out.c.jj 2011-03-17 21:34:34.000000000 +0100 +++ gcc/dwarf2out.c 2011-03-18 10:50:33.303546024 +0100 @@ -23667,7 +23667,8 @@ dwarf2out_finish (const char *filename) /* Output the address range information. We only put functions in the arange table, so don't write it out if we don't have any. */ - if (arange_table_in_use) + if ((text_section_used || cold_text_section_used || arange_table_in_use) + && info_section_emitted) { switch_to_section (debug_aranges_section); output_aranges (); Jakub