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 -- Summary: debug_ranges table contains empty range for unused .text section with -ffunction-sections Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug AssignedTo: ccoutant at gcc dot gnu dot org ReportedBy: ccoutant at gcc dot gnu dot org GCC build triplet: x86_64-unknown-linux GCC host triplet: x86_64-unknown-linux GCC target triplet: x86_64-unknown-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42454