Let --discard-all imply --strip-debug.

This will match gnu strip's behavior.

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

llvm-svn: 359887
This commit is contained in:
Sid Manning 2019-05-03 14:14:01 +00:00
parent 4d4f779fa2
commit 5ad18a7d59
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -584,6 +584,8 @@ Expected<DriverConfig> parseObjcopyOptions(ArrayRef<const char *> ArgsArr) {
Config.KeepFileSymbols = InputArgs.hasArg(OBJCOPY_keep_file_symbols); Config.KeepFileSymbols = InputArgs.hasArg(OBJCOPY_keep_file_symbols);
Config.DecompressDebugSections = Config.DecompressDebugSections =
InputArgs.hasArg(OBJCOPY_decompress_debug_sections); InputArgs.hasArg(OBJCOPY_decompress_debug_sections);
if (Config.DiscardMode == DiscardType::All)
Config.StripDebug = true;
for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol)) for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol))
Config.SymbolsToLocalize.emplace_back(Arg->getValue(), UseRegex); Config.SymbolsToLocalize.emplace_back(Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbols)) for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbols))
@ -753,6 +755,9 @@ Expected<DriverConfig> parseStripOptions(ArrayRef<const char *> ArgsArr) {
!Config.StripAllGNU && Config.SymbolsToRemove.empty()) !Config.StripAllGNU && Config.SymbolsToRemove.empty())
Config.StripAll = true; Config.StripAll = true;
if (Config.DiscardMode == DiscardType::All)
Config.StripDebug = true;
Config.DeterministicArchives = Config.DeterministicArchives =
InputArgs.hasFlag(STRIP_enable_deterministic_archives, InputArgs.hasFlag(STRIP_enable_deterministic_archives,
STRIP_disable_deterministic_archives, /*default=*/true); STRIP_disable_deterministic_archives, /*default=*/true);