[PATCH] D57440: [llvm-strip] Add --strip-symbol

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 30 02:13:30 PST 2019


evgeny777 created this revision.
evgeny777 added reviewers: phosek, jakehehrlich, rupprecht, jhenderson.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.

https://reviews.llvm.org/D57440

Files:
  test/tools/llvm-objcopy/ELF/strip-symbol.test
  tools/llvm-objcopy/CopyConfig.cpp
  tools/llvm-objcopy/StripOpts.td


Index: tools/llvm-objcopy/StripOpts.td
===================================================================
--- tools/llvm-objcopy/StripOpts.td
+++ tools/llvm-objcopy/StripOpts.td
@@ -51,6 +51,10 @@
                       MetaVarName<"section">;
 def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>;
 
+defm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
+                      MetaVarName<"symbol">;
+def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>;
+
 defm keep_section : Eq<"keep-section", "Keep <section>">,
                     MetaVarName<"section">;
 defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
Index: tools/llvm-objcopy/CopyConfig.cpp
===================================================================
--- tools/llvm-objcopy/CopyConfig.cpp
+++ tools/llvm-objcopy/CopyConfig.cpp
@@ -434,7 +434,7 @@
   Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
 
   if (!Config.StripDebug && !Config.StripUnneeded && !Config.DiscardAll &&
-      !Config.StripAllGNU)
+      !Config.StripAllGNU && !InputArgs.hasArg(STRIP_strip_symbol))
     Config.StripAll = true;
 
   for (auto Arg : InputArgs.filtered(STRIP_keep_section))
@@ -443,6 +443,9 @@
   for (auto Arg : InputArgs.filtered(STRIP_remove_section))
     Config.ToRemove.push_back(Arg->getValue());
 
+  for (auto Arg : InputArgs.filtered(STRIP_strip_symbol))
+    Config.SymbolsToRemove.push_back(Arg->getValue());
+
   for (auto Arg : InputArgs.filtered(STRIP_keep_symbol))
     Config.SymbolsToKeep.push_back(Arg->getValue());
 
Index: test/tools/llvm-objcopy/ELF/strip-symbol.test
===================================================================
--- test/tools/llvm-objcopy/ELF/strip-symbol.test
+++ test/tools/llvm-objcopy/ELF/strip-symbol.test
@@ -1,4 +1,6 @@
 # RUN: yaml2obj %s > %t
+# RUN: llvm-strip --strip-symbol baz -N bar %t -o %t2
+# RUN: llvm-readobj --symbols --sections %t2 | FileCheck %s
 # RUN: llvm-objcopy --strip-symbol baz -N bar %t %t2
 # RUN: llvm-readobj --symbols --sections %t2 | FileCheck %s
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57440.184256.patch
Type: text/x-patch
Size: 2043 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190130/36454454/attachment.bin>


More information about the llvm-commits mailing list