diff options
author | Alexander Shaposhnikov <shal1t712@gmail.com> | 2018-05-31 20:42:13 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <shal1t712@gmail.com> | 2018-05-31 20:42:13 +0000 |
commit | ecc84834b723eef4c32b8cf7fc91e3867924e0bf (patch) | |
tree | b74e29e075912a32f1d56baf3b74793e1973ae19 | |
parent | 403701140476981529a0ef0670910922804acb20 (diff) | |
download | bcm5719-llvm-ecc84834b723eef4c32b8cf7fc91e3867924e0bf.tar.gz bcm5719-llvm-ecc84834b723eef4c32b8cf7fc91e3867924e0bf.zip |
[llvm-strip] Add -o option to llvm-strip
This diff implements the option -o
for specifying a file to write the output to.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D47505
llvm-svn: 333693
-rw-r--r-- | llvm/test/tools/llvm-objcopy/strip-all.test | 19 | ||||
-rw-r--r-- | llvm/tools/llvm-objcopy/StripOpts.td | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 3 |
3 files changed, 21 insertions, 5 deletions
diff --git a/llvm/test/tools/llvm-objcopy/strip-all.test b/llvm/test/tools/llvm-objcopy/strip-all.test index e4bf4e5e654..2e935526953 100644 --- a/llvm/test/tools/llvm-objcopy/strip-all.test +++ b/llvm/test/tools/llvm-objcopy/strip-all.test @@ -1,15 +1,26 @@ # RUN: yaml2obj %s > %t +# RUN: cp %t %t3 # RUN: llvm-objcopy --strip-all %t %t2 # RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s -# We run yaml2obj again rather than copy %t to avoid interfering -# with llvm-objcopy's test (which potentially could have corrupted/updated the binary). +# Verify that the previous llvm-objcopy's run has not modified the input. +# RUN: cmp %t %t3 -# RUN: yaml2obj %s > %t3 # RUN: llvm-strip %t3 -# RUN: llvm-readobj -file-headers -sections %t3 | FileCheck %s # RUN: cmp %t2 %t3 +# RUN: cp %t %t4 +# RUN: llvm-strip %t4 -o %t5 +# RUN: cmp %t2 %t5 + +# Verify that the previous llvm-strip's run has not modified the input. +# RUN: cmp %t %t4 + +# RUN: cp %t %t-should-remain-the-same +# RUN: llvm-strip %t4 -o %t-should-remain-the-same -o %t-should-be-stripped +# RUN: cmp %t2 %t-should-be-stripped +# RUN: cmp %t %t-should-remain-the-same + !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/tools/llvm-objcopy/StripOpts.td b/llvm/tools/llvm-objcopy/StripOpts.td index 7c8862f5406..5e62a9bb499 100644 --- a/llvm/tools/llvm-objcopy/StripOpts.td +++ b/llvm/tools/llvm-objcopy/StripOpts.td @@ -7,6 +7,10 @@ multiclass Eq<string name> { def help : Flag<["-", "--"], "help">; +defm output : Eq<"o">, + MetaVarName<"output">, + HelpText<"Write output to <file>">; + def strip_debug : Flag<["-", "--"], "strip-debug">, HelpText<"Remove debugging symbols only">; diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp index da8c6ee776a..bbd21d58823 100644 --- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp +++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp @@ -582,7 +582,8 @@ CopyConfig ParseStripOptions(ArrayRef<const char *> ArgsArr) { CopyConfig Config; Config.InputFilename = Positional[0]; - Config.OutputFilename = Positional[0]; + Config.OutputFilename = + InputArgs.getLastArgValue(STRIP_output, Positional[0]); // Strip debug info only. Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug); |