[PATCH] D61092: [llvm-strip] Have --discard-all imply --strip-debug

Sid Manning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 12:26:21 PDT 2019


sidneym updated this revision to Diff 196897.
sidneym added a comment.

Make llvm-objcopy behave the same way strip does wrt --discard-all.  Update testcase


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61092/new/

https://reviews.llvm.org/D61092

Files:
  test/tools/llvm-objcopy/ELF/discard-all-debug.test
  tools/llvm-objcopy/CopyConfig.cpp


Index: tools/llvm-objcopy/CopyConfig.cpp
===================================================================
--- tools/llvm-objcopy/CopyConfig.cpp
+++ tools/llvm-objcopy/CopyConfig.cpp
@@ -573,6 +573,8 @@
   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))
@@ -740,6 +742,9 @@
       Config.DiscardMode == DiscardType::None && !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);
Index: test/tools/llvm-objcopy/ELF/discard-all-debug.test
===================================================================
--- /dev/null
+++ test/tools/llvm-objcopy/ELF/discard-all-debug.test
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61092.196897.patch
Type: text/x-patch
Size: 1628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190426/11f186e9/attachment.bin>


More information about the llvm-commits mailing list