[PATCH] D47750: [llvm-strip] Expose --discard-all option
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 18:10:20 PDT 2018
alexshap created this revision.
alexshap added reviewers: jhenderson, jakehehrlich, paulsemel.
Expose objcopy's --discard-all option in llvm-strip.
Test plan: make check-all
Repository:
rL LLVM
https://reviews.llvm.org/D47750
Files:
test/tools/llvm-objcopy/discard-all.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
@@ -588,6 +588,8 @@
if (!Config.StripDebug)
Config.StripAll = true;
+ Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
+
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
Config.ToRemove.push_back(Arg->getValue());
Index: tools/llvm-objcopy/StripOpts.td
===================================================================
--- tools/llvm-objcopy/StripOpts.td
+++ tools/llvm-objcopy/StripOpts.td
@@ -36,3 +36,8 @@
def K : JoinedOrSeparate<["-"], "K">,
Alias<keep_symbol>;
+
+def discard_all : Flag<["-", "--"], "discard-all">,
+ HelpText<"Remove all local symbols except file and section symbols">;
+def x : Flag<["-"], "x">,
+ Alias<discard_all>;
Index: test/tools/llvm-objcopy/discard-all.test
===================================================================
--- test/tools/llvm-objcopy/discard-all.test
+++ test/tools/llvm-objcopy/discard-all.test
@@ -1,8 +1,18 @@
# RUN: yaml2obj %s > %t
+# RUN: cp %t %t1
# RUN: llvm-objcopy --discard-all %t %t2
-# RUN: llvm-objcopy -x %t %t3
+# Verify that llvm-objcopy has not modified the input.
+# RUN: cmp %t %t1
# RUN: llvm-readobj -symbols %t2 | FileCheck %s
-# RUN: diff %t2 %t3
+
+# RUN: llvm-objcopy -x %t %t3
+# Verify that llvm-objcopy has not modified the input.
+# RUN: cmp %t %t1
+# RUN: cmp %t2 %t3
+
+# Verify that llvm-strip modifes the symbols table the same way.
+# RUN: llvm-strip -d --discard-all %t
+# RUN: cmp %t2 %t
!ELF
FileHeader:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47750.149883.patch
Type: text/x-patch
Size: 1669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180605/87aabeac/attachment.bin>
More information about the llvm-commits
mailing list