[llvm] r359887 - Let --discard-all imply --strip-debug.

Sid Manning via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 07:14:01 PDT 2019


Author: sidneym
Date: Fri May  3 07:14:01 2019
New Revision: 359887

URL: http://llvm.org/viewvc/llvm-project?rev=359887&view=rev
Log:
Let --discard-all imply --strip-debug.

This will match gnu strip's behavior.

Differential Revision: https://reviews.llvm.org/D61092

Added:
    llvm/trunk/test/tools/llvm-objcopy/ELF/discard-all-debug.test
Modified:
    llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp

Added: llvm/trunk/test/tools/llvm-objcopy/ELF/discard-all-debug.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/ELF/discard-all-debug.test?rev=359887&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/discard-all-debug.test (added)
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/discard-all-debug.test Fri May  3 07:14:01 2019
@@ -0,0 +1,5 @@
+# RUN: cp %p/Inputs/dwarf.dwo %t
+# RUN: llvm-strip --keep-symbol=.L.str --discard-all %t -o %t1
+# RUN: llvm-readobj --file-headers --sections %t1 | FileCheck --implicit-check-not=.debug_ %s
+# RUN: llvm-objcopy --keep-symbol=.L.str --discard-all %t %t2
+# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck --implicit-check-not=.debug_ %s

Modified: llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp?rev=359887&r1=359886&r2=359887&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/CopyConfig.cpp Fri May  3 07:14:01 2019
@@ -584,6 +584,8 @@ Expected<DriverConfig> parseObjcopyOptio
   Config.KeepFileSymbols = InputArgs.hasArg(OBJCOPY_keep_file_symbols);
   Config.DecompressDebugSections =
       InputArgs.hasArg(OBJCOPY_decompress_debug_sections);
+  if (Config.DiscardMode == DiscardType::All)
+    Config.StripDebug = true;
   for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol))
     Config.SymbolsToLocalize.emplace_back(Arg->getValue(), UseRegex);
   for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbols))
@@ -753,6 +755,9 @@ Expected<DriverConfig> parseStripOptions
       !Config.StripAllGNU && Config.SymbolsToRemove.empty())
     Config.StripAll = true;
 
+  if (Config.DiscardMode == DiscardType::All)
+    Config.StripDebug = true;
+
   Config.DeterministicArchives =
       InputArgs.hasFlag(STRIP_enable_deterministic_archives,
                         STRIP_disable_deterministic_archives, /*default=*/true);




More information about the llvm-commits mailing list