Skip to content

Commit

Permalink
Let --discard-all imply --strip-debug.
Browse files Browse the repository at this point in the history
This will match gnu strip's behavior.

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

llvm-svn: 359887
  • Loading branch information
SidManning committed May 3, 2019
1 parent 4d4f779 commit 5ad18a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/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
5 changes: 5 additions & 0 deletions llvm/tools/llvm-objcopy/CopyConfig.cpp
Expand Up @@ -584,6 +584,8 @@ Expected<DriverConfig> parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
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))
Expand Down Expand Up @@ -753,6 +755,9 @@ Expected<DriverConfig> parseStripOptions(ArrayRef<const char *> ArgsArr) {
!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);
Expand Down

0 comments on commit 5ad18a7

Please sign in to comment.