[PATCH] D62973: [llvm-objcopy] Error when --preserve-dates used on standard streams
Alex Brachet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 6 12:41:13 PDT 2019
abrachet updated this revision to Diff 203421.
abrachet added a comment.
Added a test case for --preserve-dates
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62973/new/
https://reviews.llvm.org/D62973
Files:
llvm/test/tools/llvm-objcopy/ELF/invalid-preserve-dates.test
llvm/test/tools/llvm-objcopy/ELF/preserve-dates.test
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -29,6 +29,7 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Casting.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
@@ -206,10 +207,13 @@
/// format-agnostic modifications, i.e. preserving dates.
static Error executeObjcopy(const CopyConfig &Config) {
sys::fs::file_status Stat;
- if (Config.PreserveDates)
+ if (Config.PreserveDates) {
+ if (Config.InputFilename == "-" || Config.OutputFilename == "-")
+ return createStringError(errc::invalid_argument,
+ "--preserve-dates requires a file");
if (auto EC = sys::fs::status(Config.InputFilename, Stat))
return createFileError(Config.InputFilename, EC);
-
+ }
if (Config.InputFormat == "binary") {
auto BufOrErr = MemoryBuffer::getFile(Config.InputFilename);
if (!BufOrErr)
Index: llvm/test/tools/llvm-objcopy/ELF/preserve-dates.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/preserve-dates.test
@@ -0,0 +1,5 @@
+# RUN: llvm-objcopy %p/Inputs/alloc-symtab.o %t
+# RUN: test %t -nt %p/Inputs/alloc-symtab.o
+
+# RUN: llvm-objcopy %p/Inputs/alloc-symtab.o %t --preserve-dates
+# RUN: test ! %t -nt %p/Inputs/alloc-symtab.o
Index: llvm/test/tools/llvm-objcopy/ELF/invalid-preserve-dates.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/invalid-preserve-dates.test
@@ -0,0 +1,5 @@
+# RUN: llvm-objcopy --preserve-dates - %t < %p/Inputs/alloc-symtab.o
+# CHECK: error: --preserve-dates requires a file
+
+# RUN: llvm-objcopy --preserve-dates %p/Inputs/alloc-symtab.o -
+# CHECK: error: --preserve-dates requires a file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62973.203421.patch
Type: text/x-patch
Size: 2038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190606/f03fc53d/attachment.bin>
More information about the llvm-commits
mailing list