diff options
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 95cfe24eaae..9993588cfab 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -536,7 +536,8 @@ static void EmitGenDwarfAbbrev(MCStreamer *MCOS) { MCOS->EmitULEB128IntValue(dwarf::DW_TAG_compile_unit); MCOS->EmitIntValue(dwarf::DW_CHILDREN_yes, 1); EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4); - if (MCOS->getContext().getGenDwarfSectionSyms().size() > 1) { + if (MCOS->getContext().getGenDwarfSectionSyms().size() > 1 && + MCOS->getContext().getDwarfVersion() >= 3) { EmitAbbrev(MCOS, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4); } else { EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr); @@ -873,10 +874,11 @@ void MCGenDwarfInfo::Emit(MCStreamer *MCOS) { if (MCOS->getContext().getGenDwarfSectionSyms().empty()) return; - // We only need to use the .debug_ranges section if we have multiple - // code sections. + // We only use the .debug_ranges section if we have multiple code sections, + // and we are emitting a DWARF version which supports it. const bool UseRangesSection = - MCOS->getContext().getGenDwarfSectionSyms().size() > 1; + MCOS->getContext().getGenDwarfSectionSyms().size() > 1 && + MCOS->getContext().getDwarfVersion() >= 3; CreateDwarfSectionSymbols |= UseRangesSection; MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection()); |