Index: lib/MC/MCObjectFileInfo.cpp =================================================================== --- lib/MC/MCObjectFileInfo.cpp +++ lib/MC/MCObjectFileInfo.cpp @@ -465,6 +465,13 @@ if (T.isOSSolaris() && T.getArch() != Triple::x86_64) EHSectionFlags |= ELF::SHF_WRITE; + // This is (currently) also true for MIPS + // TODO: add a T.isMIPS()? + if (PositionIndependent && + (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel || + T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el)) + EHSectionFlags |= ELF::SHF_WRITE; + // ELF BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); Index: test/MC/Mips/eh_frame-section-attrs.s =================================================================== --- /dev/null +++ test/MC/Mips/eh_frame-section-attrs.s @@ -0,0 +1,26 @@ +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-freebsd %s -o %t.o +# RUN: llvm-readobj -r -s %t.o | FileCheck %s -check-prefix OBJECT +# RUN: llvm-mc -filetype=obj -position-independent -triple=mips64-unknown-freebsd %s -o %t.o +# RUN: llvm-readobj -r -s %t.o | FileCheck %s -check-prefixes OBJECT,PIC + + + +# OBJECT-LABEL: Section { +# OBJECT: Name: .eh_frame +# OBJECT-NEXT: Type: SHT_PROGBITS (0x1) +# OBJECT-NEXT: Flags [ +# OBJECT-NEXT: SHF_ALLOC (0x2) +# For PIC we need to also emit SHF_WRITE since the relocation needs to be processed at runtime +# PIC-NEXT: SHF_WRITE (0x1) +# OBJECT-NEXT: ] + +# OBJECT-LABEL: Relocations [ +# OBJECT-NEXT: Section ({{.+}}) .rela.eh_frame { +# OBJECT-NEXT: 0x1C R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE .text 0x0 +# OBJECT-NEXT: } +# OBJECT-NEXT: ] + +func: +.cfi_startproc +lui $3, 1 +.cfi_endproc