[PATCH] D27776: LibDriver: Reject inputs that are not COFF objects or bitcode files.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 14:29:55 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289726: LibDriver: Reject inputs that are not COFF objects or bitcode files. (authored by pcc).
Changed prior to commit:
https://reviews.llvm.org/D27776?vs=81469&id=81475#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27776
Files:
llvm/trunk/lib/LibDriver/LibDriver.cpp
llvm/trunk/test/LibDriver/Inputs/cl-gl.obj
llvm/trunk/test/LibDriver/invalid.test
llvm/trunk/test/LibDriver/thin.test
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
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));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27776.81475.patch
Type: text/x-patch
Size: 1313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161214/b09c1dc2/attachment.bin>
More information about the llvm-commits
mailing list