[llvm] r334131 - [llvm-strip] Expose --discard-all option
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 14:23:20 PDT 2018
Author: alexshap
Date: Wed Jun 6 14:23:19 2018
New Revision: 334131
URL: http://llvm.org/viewvc/llvm-project?rev=334131&view=rev
Log:
[llvm-strip] Expose --discard-all option
Expose objcopy's --discard-all option in llvm-strip.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D47750
Modified:
llvm/trunk/test/tools/llvm-objcopy/discard-all.test
llvm/trunk/tools/llvm-objcopy/StripOpts.td
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
Modified: llvm/trunk/test/tools/llvm-objcopy/discard-all.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/discard-all.test?rev=334131&r1=334130&r2=334131&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/discard-all.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/discard-all.test Wed Jun 6 14:23:19 2018
@@ -1,8 +1,23 @@
# RUN: yaml2obj %s > %t
+# RUN: cp %t %t1
# RUN: llvm-objcopy --discard-all %t %t2
-# RUN: llvm-objcopy -x %t %t3
+# Verify that llvm-objcopy has not modified the input.
+# RUN: cmp %t %t1
# RUN: llvm-readobj -symbols %t2 | FileCheck %s
-# RUN: diff %t2 %t3
+
+# RUN: llvm-objcopy -x %t %t3
+# Verify that llvm-objcopy has not modified the input.
+# RUN: cmp %t %t1
+# RUN: cmp %t2 %t3
+
+# Verify that llvm-strip modifies the symbol table the same way.
+
+# RUN: cp %t %t4
+# RUN: llvm-strip --discard-all %t4
+# RUN: cmp %t2 %t4
+
+# RUN: llvm-strip -x %t
+# RUN: cmp %t2 %t
!ELF
FileHeader:
Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=334131&r1=334130&r2=334131&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Wed Jun 6 14:23:19 2018
@@ -36,3 +36,8 @@ defm keep_symbol : Eq<"keep-symbol">,
def K : JoinedOrSeparate<["-"], "K">,
Alias<keep_symbol>;
+
+def discard_all : Flag<["-", "--"], "discard-all">,
+ HelpText<"Remove all local symbols except file and section symbols">;
+def x : Flag<["-"], "x">,
+ Alias<discard_all>;
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=334131&r1=334130&r2=334131&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Wed Jun 6 14:23:19 2018
@@ -585,7 +585,10 @@ CopyConfig ParseStripOptions(ArrayRef<co
// Strip debug info only.
Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
- if (!Config.StripDebug)
+
+ Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
+
+ if (!Config.StripDebug && !Config.DiscardAll)
Config.StripAll = true;
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
More information about the llvm-commits
mailing list