Index: lld/trunk/ELF/InputFiles.h =================================================================== --- lld/trunk/ELF/InputFiles.h +++ lld/trunk/ELF/InputFiles.h @@ -272,8 +272,6 @@ bool AddedToLink = false; private: - template void addElfSymbols(); - uint64_t OffsetInArchive; }; Index: lld/trunk/ELF/InputFiles.cpp =================================================================== --- lld/trunk/ELF/InputFiles.cpp +++ lld/trunk/ELF/InputFiles.cpp @@ -1261,25 +1261,11 @@ return; } - switch (getELFKind(this->MB)) { - case ELF32LEKind: - addElfSymbols(); - return; - case ELF32BEKind: - addElfSymbols(); - return; - case ELF64LEKind: - addElfSymbols(); + if (getELFKind(this->MB) != Config->EKind) { + error("incompatible file: " + this->MB.getBufferIdentifier()); return; - case ELF64BEKind: - addElfSymbols(); - return; - default: - llvm_unreachable("getELFKind"); } -} -template void LazyObjFile::addElfSymbols() { ELFFile Obj = check(ELFFile::create(MB.getBuffer())); ArrayRef Sections = CHECK(Obj.sections(), this); Index: lld/trunk/test/ELF/lazy-arch-conflict.s =================================================================== --- lld/trunk/test/ELF/lazy-arch-conflict.s +++ lld/trunk/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: incompatible file: {{.*}}32.o