summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/LibDriver/LibDriver.cpp7
-rwxr-xr-xllvm/test/LibDriver/Inputs/cl-gl.objbin0 -> 3734 bytes
-rw-r--r--llvm/test/LibDriver/invalid.test2
-rw-r--r--llvm/test/LibDriver/thin.test2
4 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/LibDriver/LibDriver.cpp b/llvm/lib/LibDriver/LibDriver.cpp
index ea6d921d0f8..fa9f02c959d 100644
--- a/llvm/lib/LibDriver/LibDriver.cpp
+++ b/llvm/lib/LibDriver/LibDriver.cpp
@@ -143,6 +143,13 @@ int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) {
});
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));
}
diff --git a/llvm/test/LibDriver/Inputs/cl-gl.obj b/llvm/test/LibDriver/Inputs/cl-gl.obj
new file mode 100755
index 00000000000..ff746557d41
--- /dev/null
+++ b/llvm/test/LibDriver/Inputs/cl-gl.obj
Binary files differ
diff --git a/llvm/test/LibDriver/invalid.test b/llvm/test/LibDriver/invalid.test
new file mode 100644
index 00000000000..2a8b68cc60f
--- /dev/null
+++ b/llvm/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
diff --git a/llvm/test/LibDriver/thin.test b/llvm/test/LibDriver/thin.test
index 4ab9d61952b..c401de41a80 100644
--- a/llvm/test/LibDriver/thin.test
+++ b/llvm/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
OpenPOWER on IntegriCloud