[llvm] r333117 - [llvm-strip] Expose --keep-symbol option
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 23 12:44:19 PDT 2018
Author: alexshap
Date: Wed May 23 12:44:19 2018
New Revision: 333117
URL: http://llvm.org/viewvc/llvm-project?rev=333117&view=rev
Log:
[llvm-strip] Expose --keep-symbol option
Expose --keep-symbol option in llvm-strip.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D47222
Modified:
llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.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-and-keep-symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test?rev=333117&r1=333116&r2=333117&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test Wed May 23 12:44:19 2018
@@ -1,7 +1,15 @@
# RUN: yaml2obj %s > %t
+# RUN: cp %t %t1
# RUN: llvm-objcopy --strip-all --keep-symbol foo %t %t2
# RUN: llvm-readobj -sections -symbols %t2 | FileCheck %s
+# Verify that the first run of llvm-objcopy
+# has not modified the input binary.
+# RUN: cmp %t %t1
+
+# RUN: llvm-strip -keep-symbol=foo %t1
+# RUN: cmp %t1 %t2
+
!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=333117&r1=333116&r2=333117&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Wed May 23 12:44:19 2018
@@ -16,3 +16,10 @@ defm remove_section : Eq<"remove-section
def R : JoinedOrSeparate<["-"], "R">,
Alias<remove_section>;
+
+defm keep_symbol : Eq<"keep-symbol">,
+ MetaVarName<"symbol">,
+ HelpText<"Do not remove symbol <symbol>">;
+
+def K : JoinedOrSeparate<["-"], "K">,
+ Alias<keep_symbol>;
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=333117&r1=333116&r2=333117&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Wed May 23 12:44:19 2018
@@ -557,6 +557,9 @@ CopyConfig ParseStripOptions(ArrayRef<co
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
Config.ToRemove.push_back(Arg->getValue());
+
+ for (auto Arg : InputArgs.filtered(STRIP_keep_symbol))
+ Config.SymbolsToKeep.push_back(Arg->getValue());
return Config;
}
More information about the llvm-commits
mailing list