[llvm-strip] Implement --keep-file-symbols

Differential revision: https://reviews.llvm.org/D57582

llvm-svn: 352878
This commit is contained in:
Eugene Leviant 2019-02-01 15:25:15 +00:00
parent 971d4762b6
commit 05a3f9978e
3 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,11 @@
# RUN: llvm-objcopy --keep-file-symbols --strip-symbol foo %t %t2
# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=STRIP
# RUN: llvm-strip --keep-file-symbols %t -o %t3
# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=STRIPALL
# RUN: llvm-strip --keep-file-symbols --strip-symbol foo %t -o %t4
# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=STRIP
!ELF
FileHeader:
Class: ELFCLASS64

View File

@ -479,6 +479,7 @@ DriverConfig parseStripOptions(ArrayRef<const char *> ArgsArr) {
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
Config.StripAll = InputArgs.hasArg(STRIP_strip_all);
Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
Config.KeepFileSymbols = InputArgs.hasArg(STRIP_keep_file_symbols);
for (auto Arg : InputArgs.filtered(STRIP_keep_section))
Config.KeepSection.push_back(Arg->getValue());

View File

@ -59,6 +59,9 @@ defm keep_section : Eq<"keep-section", "Keep <section>">,
MetaVarName<"section">;
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
MetaVarName<"symbol">;
def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
HelpText<"Do not remove file symbols">;
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
def discard_locals : Flag<["-", "--"], "discard-locals">,