Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -1261,22 +1261,10 @@ return; } - switch (getELFKind(this->MB)) { - case ELF32LEKind: - addElfSymbols(); - return; - case ELF32BEKind: - addElfSymbols(); - return; - case ELF64LEKind: - addElfSymbols(); - return; - case ELF64BEKind: - addElfSymbols(); - return; - default: - llvm_unreachable("getELFKind"); - } + if (getELFKind(this->MB) != Config->EKind) + error(this->MB.getBufferIdentifier() + " has incompatible ELF kind"); + else + addElfSymbols(); } template void LazyObjFile::addElfSymbols() { Index: test/ELF/lazy-arch-conflict.s =================================================================== --- test/ELF/lazy-arch-conflict.s +++ test/ELF/lazy-arch-conflict.s @@ -0,0 +1,7 @@ +# REQUIRES: x86 + +# RUN: echo '.globl foo; .weak foo; .quad foo;' | llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t64.o +# RUN: echo '.globl foo; foo:' | llvm-mc -filetype=obj -triple=i686-pc-linux - -o %t32.o +# RUN: not ld.lld %t64.o --start-lib %t32.o --end-lib -o /dev/null 2>&1 | Filecheck %s + +# CHECK: error: {{.*}}32.o has incompatible ELF kind