[PATCH] D47222: [llvm-strip] Expose --keep-symbol option

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 23 12:48:23 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL333117: [llvm-strip] Expose --keep-symbol option (authored by alexshap, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47222?vs=148085&id=148273#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47222

Files:
  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


Index: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -557,6 +557,9 @@
 
   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;
 }
Index: llvm/trunk/tools/llvm-objcopy/StripOpts.td
===================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td
@@ -16,3 +16,10 @@
 
 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>;
Index: llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test
+++ llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47222.148273.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180523/a0e64a05/attachment.bin>


More information about the llvm-commits mailing list