[llvm-strip] Expose --keep-symbol option

Expose --keep-symbol option in llvm-strip.

Test plan: make check-all

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

llvm-svn: 333117
This commit is contained in:
Alexander Shaposhnikov 2018-05-23 19:44:19 +00:00
parent fe97441c2c
commit 35bee3e06b
3 changed files with 18 additions and 0 deletions

View File

@ -1,7 +1,15 @@
# RUN: yaml2obj %s > %t
# RUN: cp %t %t1
# RUN: llvm-objcopy --strip-all --keep-symbol foo %t %t2
# RUN: llvm-readobj -sections -symbols %t2 | FileCheck %s
# Verify that the first run of llvm-objcopy
# has not modified the input binary.
# RUN: cmp %t %t1
# RUN: llvm-strip -keep-symbol=foo %t1
# RUN: cmp %t1 %t2
!ELF
FileHeader:
Class: ELFCLASS64

View File

@ -16,3 +16,10 @@ defm remove_section : Eq<"remove-section">,
def R : JoinedOrSeparate<["-"], "R">,
Alias<remove_section>;
defm keep_symbol : Eq<"keep-symbol">,
MetaVarName<"symbol">,
HelpText<"Do not remove symbol <symbol>">;
def K : JoinedOrSeparate<["-"], "K">,
Alias<keep_symbol>;

View File

@ -557,6 +557,9 @@ CopyConfig ParseStripOptions(ArrayRef<const char *> ArgsArr) {
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
Config.ToRemove.push_back(Arg->getValue());
for (auto Arg : InputArgs.filtered(STRIP_keep_symbol))
Config.SymbolsToKeep.push_back(Arg->getValue());
return Config;
}