diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -331,15 +331,16 @@ break; } - unsigned EHSectionType = T.getArch() == Triple::x86_64 - ? ELF::SHT_X86_64_UNWIND - : ELF::SHT_PROGBITS; - + unsigned EHSectionType = ELF::SHT_PROGBITS; + unsigned EHSectionFlags = ELF::SHF_ALLOC; // Solaris requires different flags for .eh_frame to seemingly every other // platform. - unsigned EHSectionFlags = ELF::SHF_ALLOC; - if (T.isOSSolaris() && T.getArch() != Triple::x86_64) - EHSectionFlags |= ELF::SHF_WRITE; + if (T.isOSSolaris()) { + if (T.getArch() == Triple::x86_64) + EHSectionType = ELF::SHT_X86_64_UNWIND; + else + EHSectionFlags |= ELF::SHF_WRITE; + } // ELF BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS, 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 used to require .eh_frame to be SHT_X86_64_UNWIND and clang + // used to produce SHT_X86_64_UNWIND (since r252300). Special case the + // obsoleted type for compatibility with .section .eh_frame,"a",@unwind + if (Section->getType() != Type && Type != ELF::SHT_X86_64_UNWIND) Error(loc, "changed section type for " + SectionName + ", expected: 0x" + utohexstr(Section->getType())); if (Section->getFlags() != Flags) diff --git a/llvm/test/CodeGen/X86/eh_frame.ll b/llvm/test/CodeGen/X86/eh_frame.ll --- a/llvm/test/CodeGen/X86/eh_frame.ll +++ b/llvm/test/CodeGen/X86/eh_frame.ll @@ -7,8 +7,8 @@ @bar1 = constant i8* bitcast (i32* @foo to i8*), section "my_bar1", align 8 -; STATIC: .section .eh_frame,"a",@unwind +; STATIC: .section .eh_frame,"a",@progbits ; STATIC: .section my_bar1,"a",@progbits -; PIC: .section .eh_frame,"a",@unwind +; PIC: .section .eh_frame,"a",@progbits ; PIC: .section my_bar1,"aw",@progbits diff --git a/llvm/test/MC/ELF/cfi-adjust-cfa-offset.s b/llvm/test/MC/ELF/cfi-adjust-cfa-offset.s --- a/llvm/test/MC/ELF/cfi-adjust-cfa-offset.s +++ b/llvm/test/MC/ELF/cfi-adjust-cfa-offset.s @@ -24,7 +24,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-advance-loc2.s b/llvm/test/MC/ELF/cfi-advance-loc2.s --- a/llvm/test/MC/ELF/cfi-advance-loc2.s +++ b/llvm/test/MC/ELF/cfi-advance-loc2.s @@ -12,7 +12,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-def-cfa-offset.s b/llvm/test/MC/ELF/cfi-def-cfa-offset.s --- a/llvm/test/MC/ELF/cfi-def-cfa-offset.s +++ b/llvm/test/MC/ELF/cfi-def-cfa-offset.s @@ -13,7 +13,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-def-cfa-register.s b/llvm/test/MC/ELF/cfi-def-cfa-register.s --- a/llvm/test/MC/ELF/cfi-def-cfa-register.s +++ b/llvm/test/MC/ELF/cfi-def-cfa-register.s @@ -9,7 +9,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-def-cfa.s b/llvm/test/MC/ELF/cfi-def-cfa.s --- a/llvm/test/MC/ELF/cfi-def-cfa.s +++ b/llvm/test/MC/ELF/cfi-def-cfa.s @@ -9,7 +9,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-escape.s b/llvm/test/MC/ELF/cfi-escape.s --- a/llvm/test/MC/ELF/cfi-escape.s +++ b/llvm/test/MC/ELF/cfi-escape.s @@ -10,7 +10,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-large-model.s b/llvm/test/MC/ELF/cfi-large-model.s --- a/llvm/test/MC/ELF/cfi-large-model.s +++ b/llvm/test/MC/ELF/cfi-large-model.s @@ -9,7 +9,7 @@ // CHECK-X86: Section { // CHECK-X86: Index: // CHECK-X86: Name: .eh_frame -// CHECK-X86-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-X86-NEXT: Type: SHT_PROGBITS // CHECK-X86-NEXT: Flags [ // CHECK-X86-NEXT: SHF_ALLOC // CHECK-X86-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-offset.s b/llvm/test/MC/ELF/cfi-offset.s --- a/llvm/test/MC/ELF/cfi-offset.s +++ b/llvm/test/MC/ELF/cfi-offset.s @@ -9,7 +9,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-register.s b/llvm/test/MC/ELF/cfi-register.s --- a/llvm/test/MC/ELF/cfi-register.s +++ b/llvm/test/MC/ELF/cfi-register.s @@ -10,7 +10,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-rel-offset.s b/llvm/test/MC/ELF/cfi-rel-offset.s --- a/llvm/test/MC/ELF/cfi-rel-offset.s +++ b/llvm/test/MC/ELF/cfi-rel-offset.s @@ -17,7 +17,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-rel-offset2.s b/llvm/test/MC/ELF/cfi-rel-offset2.s --- a/llvm/test/MC/ELF/cfi-rel-offset2.s +++ b/llvm/test/MC/ELF/cfi-rel-offset2.s @@ -9,7 +9,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-remember.s b/llvm/test/MC/ELF/cfi-remember.s --- a/llvm/test/MC/ELF/cfi-remember.s +++ b/llvm/test/MC/ELF/cfi-remember.s @@ -12,7 +12,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-restore.s b/llvm/test/MC/ELF/cfi-restore.s --- a/llvm/test/MC/ELF/cfi-restore.s +++ b/llvm/test/MC/ELF/cfi-restore.s @@ -10,7 +10,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-same-value.s b/llvm/test/MC/ELF/cfi-same-value.s --- a/llvm/test/MC/ELF/cfi-same-value.s +++ b/llvm/test/MC/ELF/cfi-same-value.s @@ -10,7 +10,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-signal-frame.s b/llvm/test/MC/ELF/cfi-signal-frame.s --- a/llvm/test/MC/ELF/cfi-signal-frame.s +++ b/llvm/test/MC/ELF/cfi-signal-frame.s @@ -11,7 +11,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-undefined.s b/llvm/test/MC/ELF/cfi-undefined.s --- a/llvm/test/MC/ELF/cfi-undefined.s +++ b/llvm/test/MC/ELF/cfi-undefined.s @@ -10,7 +10,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-window-save.s b/llvm/test/MC/ELF/cfi-window-save.s --- a/llvm/test/MC/ELF/cfi-window-save.s +++ b/llvm/test/MC/ELF/cfi-window-save.s @@ -12,7 +12,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi-zero-addr-delta.s b/llvm/test/MC/ELF/cfi-zero-addr-delta.s --- a/llvm/test/MC/ELF/cfi-zero-addr-delta.s +++ b/llvm/test/MC/ELF/cfi-zero-addr-delta.s @@ -16,7 +16,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] diff --git a/llvm/test/MC/ELF/cfi.s b/llvm/test/MC/ELF/cfi.s --- a/llvm/test/MC/ELF/cfi.s +++ b/llvm/test/MC/ELF/cfi.s @@ -220,7 +220,7 @@ // CHECK: Section { // CHECK: Index: // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ] 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 @@ -8,4 +8,8 @@ # CHECK: {{.*}}.s:[[# @LINE+1]]:1: error: changed section type for .foo, expected: 0x1 .pushsection .foo,"a",@nobits +# clang used to produce SHT_X86_64_UNWIND for .eh_frame . We don't want to +# error on them. For simplicity, we allow all sections names. +.pushsection .foo,"a",@unwind + .pushsection .foo,"a",@progbits diff --git a/llvm/test/MC/ELF/section.s b/llvm/test/MC/ELF/section.s --- a/llvm/test/MC/ELF/section.s +++ b/llvm/test/MC/ELF/section.s @@ -112,7 +112,7 @@ // CHECK: Section { // CHECK: Name: .eh_frame -// CHECK-NEXT: Type: SHT_X86_64_UNWIND +// CHECK-NEXT: Type: SHT_PROGBITS // CHECK-NEXT: Flags [ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: ]