[PATCH] D47818: [llvm-strip] Expose --strip-unneeded option
Paul Semel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 03:43:08 PDT 2018
paulsemel created this revision.
paulsemel added reviewers: echristo, jakehehrlich, jhenderson, alexshap.
Repository:
rL LLVM
https://reviews.llvm.org/D47818
Files:
test/tools/llvm-objcopy/strip-unneeded.test
tools/llvm-objcopy/StripOpts.td
tools/llvm-objcopy/llvm-objcopy.cpp
Index: tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- tools/llvm-objcopy/llvm-objcopy.cpp
+++ tools/llvm-objcopy/llvm-objcopy.cpp
@@ -585,7 +585,10 @@
// Strip debug info only.
Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
- if (!Config.StripDebug)
+
+ Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
+
+ if (!Config.StripDebug && !Config.StripUnneeded)
Config.StripAll = true;
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
Index: tools/llvm-objcopy/StripOpts.td
===================================================================
--- tools/llvm-objcopy/StripOpts.td
+++ tools/llvm-objcopy/StripOpts.td
@@ -36,3 +36,5 @@
def K : JoinedOrSeparate<["-"], "K">,
Alias<keep_symbol>;
+def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
+ HelpText<"Remove all symbols not needed by relocations">;
Index: test/tools/llvm-objcopy/strip-unneeded.test
===================================================================
--- test/tools/llvm-objcopy/strip-unneeded.test
+++ test/tools/llvm-objcopy/strip-unneeded.test
@@ -1,6 +1,13 @@
# 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: cp %t %t3
+# RUN: llvm-strip --strip-unneeded %t3
+# RUN: cmp %t2 %t3
!ELF
FileHeader:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47818.150102.patch
Type: text/x-patch
Size: 1560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180606/0a4087f9/attachment.bin>
More information about the llvm-commits
mailing list