[llvm] r352746 - [llvm-strip] Add --strip-symbol

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 04:16:21 PST 2019


Author: evgeny777
Date: Thu Jan 31 04:16:20 2019
New Revision: 352746

URL: http://llvm.org/viewvc/llvm-project?rev=352746&view=rev
Log:
[llvm-strip] Add --strip-symbol

Differential revision: https://reviews.llvm.org/D57440

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

Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/strip-symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/strip-symbol.test?rev=352746&r1=352745&r2=352746&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/strip-symbol.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/strip-symbol.test Thu Jan 31 04:16:20 2019
@@ -1,6 +1,8 @@
 # RUN: yaml2obj %s > %t
 # RUN: llvm-objcopy --strip-symbol baz -N bar %t %t2
 # RUN: llvm-readobj --symbols --sections %t2 | FileCheck %s
+# RUN: llvm-strip --strip-symbol baz -N bar %t -o %t3
+# RUN: llvm-readobj --symbols --sections %t3 | FileCheck %s
 
 !ELF
 FileHeader:

Modified: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp?rev=352746&r1=352745&r2=352746&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp Thu Jan 31 04:16:20 2019
@@ -480,19 +480,22 @@ DriverConfig parseStripOptions(ArrayRef<
   Config.StripAll = InputArgs.hasArg(STRIP_strip_all);
   Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
 
-  if (!Config.StripDebug && !Config.StripUnneeded &&
-      Config.DiscardMode == DiscardType::None && !Config.StripAllGNU)
-    Config.StripAll = true;
-
   for (auto Arg : InputArgs.filtered(STRIP_keep_section))
     Config.KeepSection.push_back(Arg->getValue());
 
   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());
 
+  if (!Config.StripDebug && !Config.StripUnneeded &&
+      Config.DiscardMode == DiscardType::None && !Config.StripAllGNU && Config.SymbolsToRemove.empty())
+    Config.StripAll = true;
+
   Config.DeterministicArchives =
       InputArgs.hasFlag(STRIP_enable_deterministic_archives,
                         STRIP_disable_deterministic_archives, /*default=*/true);

Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=352746&r1=352745&r2=352746&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Thu Jan 31 04:16:20 2019
@@ -51,6 +51,10 @@ defm remove_section : Eq<"remove-section
                       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>">,




More information about the llvm-commits mailing list