diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -637,7 +637,10 @@ MCSectionELF *Section = getContext().getELFSection( SectionName, Type, Flags, Size, GroupName, UniqueID, LinkedToSym); getStreamer().SwitchSection(Section, Subsection); - if (Section->getType() != Type) + // x86-64 psABI names SHT_X86_64_UNWIND as the canonical type for .eh_frame + // but allows SHT_PROGBITS as an alternative type. + if (Section->getType() != Type && + !(SectionName == ".eh_frame" && Type == ELF::SHT_PROGBITS)) Error(loc, "changed section type for " + SectionName + ", expected: 0x" + utohexstr(Section->getType())); if (Section->getFlags() != Flags) diff --git a/llvm/test/MC/ELF/section-type-changed.s b/llvm/test/MC/ELF/section-type-changed.s --- a/llvm/test/MC/ELF/section-type-changed.s +++ b/llvm/test/MC/ELF/section-type-changed.s @@ -9,3 +9,10 @@ .pushsection .foo,"a",@nobits .pushsection .foo,"a",@progbits + + +# SHT_X86_64_UNWIND x86-64 psABI +# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section type for .eh_frame, expected: 0x70000001 +.pushsection .eh_frame,"a",@progbits + +.pushsection .eh_frame,"a",@unwind