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,11 @@ 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 GNU as emits SHT_PROGBITS .eh_frame for .cfi_* directives. Don't error + // for SHT_PROGBITS .eh_frame + 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,11 @@ .pushsection .foo,"a",@nobits .pushsection .foo,"a",@progbits + +## GNU as emits SHT_PROGBITS .eh_frame for .cfi_* directives. Don't error. +.section .eh_frame,"a",@progbits +.section .eh_frame,"a",@unwind +.pushsection .eh_frame,"a",@progbits + +# CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section type for .eh_frame, expected: 0x70000001 +.section .eh_frame,"a",@nobits