[llvm] r368241 - [llvm-strip] Support --strip-sections
Wolfgang Pieb via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 17:35:16 PDT 2019
Author: wolfgangp
Date: Wed Aug 7 17:35:16 2019
New Revision: 368241
URL: http://llvm.org/viewvc/llvm-project?rev=368241&view=rev
Log:
[llvm-strip] Support --strip-sections
llvm-objcopy already supports --strip-sections. It is a good fit for its alias llvm-strip
to support it as well.
Reviewers: rupprecht, jhenderson
Differential Revision: https://reviews.llvm.org/D65787
Modified:
llvm/trunk/test/tools/llvm-objcopy/ELF/strip-sections.test
llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
llvm/trunk/tools/llvm-objcopy/StripOpts.td
Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/strip-sections.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/strip-sections.test?rev=368241&r1=368240&r2=368241&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/strip-sections.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/strip-sections.test Wed Aug 7 17:35:16 2019
@@ -8,6 +8,11 @@
# RUN: llvm-objcopy %t %t3
# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --check-prefix=VALIDATE
+## Check that llvm-strip --strip-sections is equivalent to
+## llvm-objcopy --strip-sections.
+# RUN: llvm-strip --strip-sections %t -o %t4
+# RUN: cmp %t2 %t4
+
!ELF
FileHeader:
Class: ELFCLASS64
Modified: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp?rev=368241&r1=368240&r2=368241&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp Wed Aug 7 17:35:16 2019
@@ -810,6 +810,7 @@ parseStripOptions(ArrayRef<const char *>
InputArgs.hasFlag(STRIP_discard_all, STRIP_discard_locals)
? DiscardType::All
: DiscardType::Locals;
+ Config.StripSections = InputArgs.hasArg(STRIP_strip_sections);
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
if (auto Arg = InputArgs.getLastArg(STRIP_strip_all, STRIP_no_strip_all))
Config.StripAll = Arg->getOption().getID() == STRIP_strip_all;
Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=368241&r1=368240&r2=368241&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Wed Aug 7 17:35:16 2019
@@ -52,6 +52,9 @@ def strip_debug : Flag<["--"], "strip-de
def d : Flag<["-"], "d">, Alias<strip_debug>;
def g : Flag<["-"], "g">, Alias<strip_debug>;
def S : Flag<["-"], "S">, Alias<strip_debug>;
+def strip_sections
+ : Flag<["--"], "strip-sections">,
+ HelpText<"Remove all section headers and all sections not in segments">;
def strip_unneeded : Flag<["--"], "strip-unneeded">,
HelpText<"Remove all symbols not needed by relocations">;
More information about the llvm-commits
mailing list