[PATCH] D47818: [llvm-strip] Expose --strip-unneeded option

Paul Semel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 7 03:09:54 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334182: [llvm-strip] Expose --strip-unneeded option (authored by paulsemel, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47818?vs=150114&id=150286#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47818

Files:
  llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test
  llvm/trunk/tools/llvm-objcopy/StripOpts.td
  llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp


Index: llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test
+++ llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test
@@ -1,7 +1,14 @@
 # RUN: yaml2obj %s > %t
+# RUN: cp %t %t1
 # RUN: llvm-objcopy --strip-unneeded %t %t2
+# Verify that llvm-objcopy has not modified the input.
+# RUN: cmp %t %t1
 # RUN: llvm-readobj -symbols %t2 | FileCheck %s
 
+# Verify that llvm-strip modifies the symbol table the same way.
+# RUN: llvm-strip --strip-unneeded %t
+# RUN: cmp %t %t2
+
 !ELF
 FileHeader:
   Class:           ELFCLASS64
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
@@ -583,12 +583,12 @@
   Config.OutputFilename =
       InputArgs.getLastArgValue(STRIP_output, Positional[0]);
 
-  // Strip debug info only.
   Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
   
   Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
-  
-  if (!Config.StripDebug && !Config.DiscardAll)
+  Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
+
+  if (!Config.StripDebug && !Config.StripUnneeded && !Config.DiscardAll)
     Config.StripAll = true;
 
   for (auto Arg : InputArgs.filtered(STRIP_remove_section))
Index: llvm/trunk/tools/llvm-objcopy/StripOpts.td
===================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td
@@ -41,3 +41,6 @@
                   HelpText<"Remove all local symbols except file and section symbols">;
 def x : Flag<["-"], "x">,
         Alias<discard_all>;
+
+def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
+                      HelpText<"Remove all symbols not needed by relocations">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47818.150286.patch
Type: text/x-patch
Size: 1950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180607/74f65af6/attachment.bin>


More information about the llvm-commits mailing list