Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -324,6 +324,8 @@ MipsReginfo.reset(new MipsReginfoInputSection(this, &Sec, Name)); return MipsReginfo.get(); case SHT_MIPS_OPTIONS: + if (MipsOptions) + fatal("Multiple SHT_MIPS_OPTIONS sections are not allowed"); MipsOptions.reset(new MipsOptionsInputSection(this, &Sec, Name)); return MipsOptions.get(); case SHT_MIPS_ABIFLAGS: Index: test/ELF/invalid/mips-multiple-options.test =================================================================== --- test/ELF/invalid/mips-multiple-options.test +++ test/ELF/invalid/mips-multiple-options.test @@ -0,0 +1,25 @@ +# RUN: yaml2obj %s -o %t +# RUN: not ld.lld %t -o %tout 2>&1 | FileCheck %s + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32] + +Sections: + - Name: .o1 + Type: SHT_MIPS_OPTIONS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 16 + Content: "010000000000000000000000" + + - Name: .o2 + Type: SHT_MIPS_OPTIONS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 16 + Content: "010000000000000000000000" + +# CHECK: Multiple SHT_MIPS_OPTIONS sections are not allowed