[llvm] r334182 - [llvm-strip] Expose --strip-unneeded option
Paul Semel via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 7 03:05:25 PDT 2018
Author: paulsemel
Date: Thu Jun 7 03:05:25 2018
New Revision: 334182
URL: http://llvm.org/viewvc/llvm-project?rev=334182&view=rev
Log:
[llvm-strip] Expose --strip-unneeded option
Differential Revision: https://reviews.llvm.org/D47818
Modified:
llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test
llvm/trunk/tools/llvm-objcopy/StripOpts.td
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
Modified: llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test?rev=334182&r1=334181&r2=334182&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/strip-unneeded.test Thu Jun 7 03:05:25 2018
@@ -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
Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=334182&r1=334181&r2=334182&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Thu Jun 7 03:05:25 2018
@@ -41,3 +41,6 @@ def discard_all : Flag<["-", "--"], "dis
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">;
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=334182&r1=334181&r2=334182&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Thu Jun 7 03:05:25 2018
@@ -583,12 +583,12 @@ CopyConfig ParseStripOptions(ArrayRef<co
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))
More information about the llvm-commits
mailing list