diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 |
2 files changed, 7 insertions, 5 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()); diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 98b2b3bd60b..e3020040e57 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -555,7 +555,7 @@ EndStmt: std::make_pair(ELFSection, std::make_pair(nullptr, nullptr))); if (InsertResult.second) { if (getContext().getDwarfVersion() <= 2) - Error(loc, "DWARF2 only supports one section per compilation unit"); + Warning(loc, "DWARF2 only supports one section per compilation unit"); MCSymbol *SectionStartSymbol = getContext().CreateTempSymbol(); getStreamer().EmitLabel(SectionStartSymbol); |