[llvm] r356207 - [llvm-strip] Hook up (unimplemented) --only-keep-debug
Jordan Rupprecht via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 14:51:42 PDT 2019
Author: rupprecht
Date: Thu Mar 14 14:51:42 2019
New Revision: 356207
URL: http://llvm.org/viewvc/llvm-project?rev=356207&view=rev
Log:
[llvm-strip] Hook up (unimplemented) --only-keep-debug
For ELF, we accept but ignore --only-keep-debug. Do the same for llvm-strip.
COFF does implement this, so update the test that it is supported.
Modified:
llvm/trunk/test/tools/llvm-objcopy/COFF/only-keep-debug.test
llvm/trunk/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test
llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td
llvm/trunk/tools/llvm-objcopy/StripOpts.td
Modified: llvm/trunk/test/tools/llvm-objcopy/COFF/only-keep-debug.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/COFF/only-keep-debug.test?rev=356207&r1=356206&r2=356207&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/COFF/only-keep-debug.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/COFF/only-keep-debug.test Thu Mar 14 14:51:42 2019
@@ -3,6 +3,10 @@ RUN: yaml2obj %p/Inputs/only-keep-sectio
RUN: llvm-objcopy --only-keep-debug %t.in.exe %t.out.exe
RUN: llvm-readobj --sections %t.out.exe | FileCheck %s --check-prefix=SECTIONS
RUN: llvm-objdump -t %t.out.exe | FileCheck %s --check-prefix=SYMBOLS
+# Run llvm-strip with --strip-symbol on a non-existent symbol to prevent
+# defaulting to --strip-all.
+RUN: llvm-strip --only-keep-debug --strip-symbol foo %t.in.exe -o %t-strip.out.exe
+RUN: cmp %t.out.exe %t-strip.out.exe
Check that all non-debug/buildid sections with IMAGE_SCN_CNT_CODE
or IMAGE_SCN_CNT_INITIALIZED_DATA are truncated, and no others.
Modified: llvm/trunk/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test?rev=356207&r1=356206&r2=356207&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test Thu Mar 14 14:51:42 2019
@@ -6,6 +6,10 @@
# RUN: llvm-objcopy %t %t2
# RUN: llvm-objcopy --only-keep-debug %t %t3
# RUN: cmp %t2 %t3
+# Run llvm-strip with --strip-symbol on a non-existent symbol to prevent
+# defaulting to --strip-all.
+# RUN: llvm-strip --only-keep-debug --strip-symbol foo %t -o %t4
+# RUN: cmp %t2 %t4
!ELF
FileHeader:
Modified: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp?rev=356207&r1=356206&r2=356207&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp Thu Mar 14 14:51:42 2019
@@ -725,6 +725,7 @@ Expected<DriverConfig> parseStripOptions
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
Config.StripAll = InputArgs.hasArg(STRIP_strip_all);
Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
+ Config.OnlyKeepDebug = InputArgs.hasArg(STRIP_only_keep_debug);
Config.KeepFileSymbols = InputArgs.hasArg(STRIP_keep_file_symbols);
for (auto Arg : InputArgs.filtered(STRIP_keep_section))
Modified: llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td?rev=356207&r1=356206&r2=356207&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td Thu Mar 14 14:51:42 2019
@@ -206,9 +206,12 @@ def N : JoinedOrSeparate<["-"], "N">, Al
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
MetaVarName<"symbol">;
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
+
def only_keep_debug
: Flag<["-", "--"], "only-keep-debug">,
- HelpText<"Currently ignored. Only for compatibility with GNU objcopy.">;
+ HelpText<"Clear sections that would not be stripped by --strip-debug. "
+ "Currently only implemented for COFF.">;
+
def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
HelpText<"Do not remove file symbols">;
defm dump_section
Modified: llvm/trunk/tools/llvm-objcopy/StripOpts.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/StripOpts.td?rev=356207&r1=356206&r2=356207&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/StripOpts.td (original)
+++ llvm/trunk/tools/llvm-objcopy/StripOpts.td Thu Mar 14 14:51:42 2019
@@ -63,6 +63,11 @@ def keep_file_symbols : Flag<["-", "--"]
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
+def only_keep_debug
+ : Flag<["-", "--"], "only-keep-debug">,
+ HelpText<"Clear sections that would not be stripped by --strip-debug. "
+ "Currently only implemented for COFF.">;
+
def discard_locals : Flag<["-", "--"], "discard-locals">,
HelpText<"Remove compiler-generated local symbols, (e.g. "
"symbols starting with .L)">;
More information about the llvm-commits
mailing list