[PATCH] D47818: [llvm-strip] Expose --strip-unneeded option
Paul Semel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 05:22:32 PDT 2018
paulsemel updated this revision to Diff 150114.
paulsemel marked 2 inline comments as done.
paulsemel added a comment.
Added Jame's suggestions
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,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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47818.150114.patch
Type: text/x-patch
Size: 1573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180606/89973865/attachment.bin>
More information about the llvm-commits
mailing list