Index: llvm/trunk/lib/LibDriver/LibDriver.cpp =================================================================== --- llvm/trunk/lib/LibDriver/LibDriver.cpp +++ llvm/trunk/lib/LibDriver/LibDriver.cpp @@ -143,6 +143,13 @@ }); return 1; } + sys::fs::file_magic Magic = + sys::fs::identify_magic(MOrErr->Buf->getBuffer()); + if (Magic != sys::fs::file_magic::coff_object && + Magic != sys::fs::file_magic::bitcode) { + llvm::errs() << Arg->getValue() << ": not a COFF object or bitcode file\n"; + return 1; + } Members.emplace_back(std::move(*MOrErr)); } Index: llvm/trunk/test/LibDriver/invalid.test =================================================================== --- llvm/trunk/test/LibDriver/invalid.test +++ llvm/trunk/test/LibDriver/invalid.test @@ -0,0 +1,2 @@ +RUN: not llvm-lib %S/Inputs/cl-gl.obj 2>&1 | FileCheck %s +CHECK: not a COFF object or bitcode file Index: llvm/trunk/test/LibDriver/thin.test =================================================================== --- llvm/trunk/test/LibDriver/thin.test +++ llvm/trunk/test/LibDriver/thin.test @@ -1,4 +1,4 @@ -RUN: echo foo > %t +RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t %S/Inputs/a.s RUN: llvm-lib -out:%t.a %t RUN: FileCheck --check-prefix=FAT %s < %t.a