[llvm] r333693 - [llvm-strip] Add -o option to llvm-strip
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Thu May 31 13:42:13 PDT 2018
Author: alexshap
Date: Thu May 31 13:42:13 2018
New Revision: 333693
URL: http://llvm.org/viewvc/llvm-project?rev=333693&view=rev
Log:
[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
Modified:
llvm/trunk/test/tools/llvm-objcopy/strip-all.test
llvm/trunk/tools/llvm-objcopy/StripOpts.td
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
Modified: llvm/trunk/test/tools/llvm-objcopy/strip-all.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/strip-all.test?rev=333693&r1=333692&r2=333693&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-all.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/strip-all.test Thu May 31 13:42:13 2018
@@ -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
Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=333693&r1=333692&r2=333693&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Thu May 31 13:42:13 2018
@@ -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">;
Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=333693&r1=333692&r2=333693&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Thu May 31 13:42:13 2018
@@ -582,7 +582,8 @@ CopyConfig ParseStripOptions(ArrayRef<co
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);
More information about the llvm-commits
mailing list