When -ffunction-sections is turned on with -g2, gcc emits an entry into the .debug_ranges section for the DW_TAG_compile_unit for the range (.Ltext, .Letext) unconditionally. With -ffunction-sections, the .text section remains unused, and this entry in .debug_ranges refers to a zero-length range. That's not normally a problem, but when --gc-sections is turned on in the linker, the empty .text section can be removed, and the relocations for that range apply zeroes to that entry, and it now looks like the end of the range list. Because that's actually the first range entry that gcc emits for the compile unit, DWARF consumers see an empty range list. This causes significant slowdowns for objdump and addr2line. Example: $ cat foo.c int foo(int i) { return i + 1; } int bar(int i) { return i + 2; } $ gcc -S -dA -g -ffunction-sections foo.c The resulting assembly code has this: .text .Ltext0: .section .text.foo,"ax",@progbits .globl foo .type foo, @function foo: .LFB0: ... .text .Letext0: ... .section .debug_ranges,"",@progbits .Ldebug_ranges0: .quad .Ltext0 # Offset 0x0 .quad .Letext0 .quad .LFB0 # Offset 0x10 .quad .LFE0 .quad .LFB1 # Offset 0x20 .quad .LFE1 .quad 0x0 .quad 0x0
Created attachment 19363 [details] Proposed fix for PR 42454 * dwarf2out.c (dwarf2out_finish): Don't output range for .text section unless .text section was used. Likewise for cold.
Subject: Bug 42454 Author: ccoutant Date: Tue Dec 22 17:37:57 2009 New Revision: 155402 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155402 Log: PR debug/42454 * dwarf2out.c (dwarf2out_finish): Don't output range for .text section unless .text section was used. Likewise for cold. Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c
Fixed at r155402.
Caused a regression: If !text_section_used, would omit the DW_AT_ranges attribute from the compile_unit DIE.
Subject: Bug 42454 Author: jakub Date: Wed Dec 23 16:54:35 2009 New Revision: 155429 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155429 Log: PR debug/42454 * dwarf2out.c (add_ranges_by_labels_to_AT_range_list): New function. (dwarf2out_finish): Call add_ranges_by_labels_to_AT_range_list. * gcc.dg/debug/dwarf2/aranges-fnsec-1.c: Add check for .debug_ranges. Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/debug/dwarf2/aranges-fnsec-1.c
Fixed.
Subject: Bug 42454 Author: grosser Date: Mon Jun 7 20:59:33 2010 New Revision: 160403 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=160403 Log: Merge some commits missed during a merge from mainline in Dez 2009. * README: Mention changes to Makefile.in and functions.texi. * gather-docs: Mention 'make stamp-functions' in the header. svn+ssh://gcc.gnu.org/svn/gcc/trunk@154545 * functions.texi: Rebuild. svn+ssh://gcc.gnu.org/svn/gcc/trunk@154546 Fix PR target/40887 2009-12-24 Julian Brown <julian@codesourcery.com> Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> PR target/40887 * config/arm/arm.c (output_call_mem): Remove armv5 support. * config/arm/arm.md (*call_mem): Disable for armv5. Add note. (*call_value_mem): Likewise. PR target/40887 * gcc.target/gcc.arm/pr40887.c: New test. svn+ssh://gcc.gnu.org/svn/gcc/trunk@155453 Fix PR target/42093 2009-12-23 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> PR target/42093 * config/arm/arm.h (CASE_VECTOR_PC_RELATIVE): Fix macro usage to TARGET_THUMB1. (CASE_VECTOR_SHORTEN_MODE): Allow signed offsets only for TARGET_THUMB1. 2009-12-23 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> PR target/42093 * gcc.target/arm/pr42093.c: New test. svn+ssh://gcc.gnu.org/svn/gcc/trunk@155428 PR debug/42454 * dwarf2out.c (add_ranges_by_labels_to_AT_range_list): New function. (dwarf2out_finish): Call add_ranges_by_labels_to_AT_range_list. * gcc.dg/debug/dwarf2/aranges-fnsec-1.c: Add check for .debug_ranges. svn+ssh://gcc.gnu.org/svn/gcc/trunk@155429 Added: branches/graphite/gcc/testsuite/gcc.target/arm/pr40887.c branches/graphite/gcc/testsuite/gcc.target/arm/pr42093.c Modified: branches/graphite/gcc/config/arm/arm.c branches/graphite/gcc/config/arm/arm.h branches/graphite/gcc/config/arm/arm.md branches/graphite/gcc/dwarf2out.c branches/graphite/gcc/testsuite/gcc.dg/debug/dwarf2/aranges-fnsec-1.c branches/graphite/libiberty/README branches/graphite/libiberty/functions.texi branches/graphite/libiberty/gather-docs