forked from OSchip/llvm-project
[llvm-strip] Support --keep and --strip-all-gnu from llvm-objcopy
Summary: Add --keep and --strip-all-gnu from llvm-objcopy into llvm-strip. Reviewers: jakehehrlich, jhenderson, alexshap Reviewed By: jhenderson, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53954 llvm-svn: 345861
This commit is contained in:
parent
49996c1d99
commit
30d1b19b0b
|
@ -1,6 +1,8 @@
|
||||||
# RUN: yaml2obj %s > %t
|
# RUN: yaml2obj %s > %t
|
||||||
# RUN: llvm-objcopy -strip-non-alloc -keep=.test %t %t2
|
# RUN: llvm-objcopy -strip-non-alloc -keep=.test %t %t2
|
||||||
|
# RUN: llvm-strip --strip-all -keep=.test %t -o %t3
|
||||||
# RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s
|
# RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s
|
||||||
|
# RUN: cmp %t2 %t3
|
||||||
|
|
||||||
!ELF
|
!ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
# RUN: yaml2obj %s > %t
|
# RUN: yaml2obj %s > %t
|
||||||
# RUN: cp %t %t1
|
# RUN: cp %t %t1
|
||||||
# RUN: llvm-objcopy --strip-all-gnu %t %t2
|
# RUN: llvm-objcopy --strip-all-gnu %t %t2
|
||||||
|
# RUN: llvm-strip --strip-all-gnu %t -o %t3
|
||||||
# RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s
|
# RUN: llvm-readobj -file-headers -sections %t2 | FileCheck %s
|
||||||
|
# RUN: cmp %t2 %t3
|
||||||
|
|
||||||
!ELF
|
!ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
|
|
|
@ -405,10 +405,15 @@ DriverConfig parseStripOptions(ArrayRef<const char *> ArgsArr) {
|
||||||
Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
|
Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
|
||||||
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
|
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
|
||||||
Config.StripAll = InputArgs.hasArg(STRIP_strip_all);
|
Config.StripAll = InputArgs.hasArg(STRIP_strip_all);
|
||||||
|
Config.StripAllGNU = InputArgs.hasArg(STRIP_strip_all_gnu);
|
||||||
|
|
||||||
if (!Config.StripDebug && !Config.StripUnneeded && !Config.DiscardAll)
|
if (!Config.StripDebug && !Config.StripUnneeded && !Config.DiscardAll &&
|
||||||
|
!Config.StripAllGNU)
|
||||||
Config.StripAll = true;
|
Config.StripAll = true;
|
||||||
|
|
||||||
|
for (auto Arg : InputArgs.filtered(STRIP_keep))
|
||||||
|
Config.Keep.push_back(Arg->getValue());
|
||||||
|
|
||||||
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
|
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
|
||||||
Config.ToRemove.push_back(Arg->getValue());
|
Config.ToRemove.push_back(Arg->getValue());
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ def strip_all : Flag<["-", "--"], "strip-all">,
|
||||||
def S : Flag<["-"], "S">,
|
def S : Flag<["-"], "S">,
|
||||||
Alias<strip_all>;
|
Alias<strip_all>;
|
||||||
def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
|
def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
|
||||||
HelpText<"Compaitable with GNU objcopy's --strip-all">;
|
HelpText<"Compatible with GNU objcopy's --strip-all">;
|
||||||
def strip_debug : Flag<["-", "--"], "strip-debug">,
|
def strip_debug : Flag<["-", "--"], "strip-debug">,
|
||||||
HelpText<"Remove all debug information">;
|
HelpText<"Remove all debug information">;
|
||||||
def strip_dwo : Flag<["-", "--"], "strip-dwo">,
|
def strip_dwo : Flag<["-", "--"], "strip-dwo">,
|
||||||
|
@ -142,7 +142,7 @@ defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
|
||||||
def K : JoinedOrSeparate<["-"], "K">,
|
def K : JoinedOrSeparate<["-"], "K">,
|
||||||
Alias<keep_symbol>;
|
Alias<keep_symbol>;
|
||||||
def only_keep_debug : Flag<["-", "--"], "only-keep-debug">,
|
def only_keep_debug : Flag<["-", "--"], "only-keep-debug">,
|
||||||
HelpText<"Currently ignored. Only for compaitability with GNU objcopy.">;
|
HelpText<"Currently ignored. Only for compatibility with GNU objcopy.">;
|
||||||
def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
|
def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
|
||||||
HelpText<"Remove all symbols not needed by relocations">;
|
HelpText<"Remove all symbols not needed by relocations">;
|
||||||
def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
|
def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
|
||||||
|
|
|
@ -38,6 +38,9 @@ def strip_all : Flag<["-", "--"], "strip-all">,
|
||||||
def s : Flag<["-"], "s">,
|
def s : Flag<["-"], "s">,
|
||||||
Alias<strip_all>;
|
Alias<strip_all>;
|
||||||
|
|
||||||
|
def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
|
||||||
|
HelpText<"Compatible with GNU strip's --strip-all">;
|
||||||
|
|
||||||
def strip_debug : Flag<["-", "--"], "strip-debug">,
|
def strip_debug : Flag<["-", "--"], "strip-debug">,
|
||||||
HelpText<"Remove debugging symbols only">;
|
HelpText<"Remove debugging symbols only">;
|
||||||
|
|
||||||
|
@ -56,6 +59,8 @@ defm remove_section : Eq<"remove-section", "Remove <section>">,
|
||||||
def R : JoinedOrSeparate<["-"], "R">,
|
def R : JoinedOrSeparate<["-"], "R">,
|
||||||
Alias<remove_section>;
|
Alias<remove_section>;
|
||||||
|
|
||||||
|
defm keep : Eq<"keep", "Keep <section>">, MetaVarName<"section">;
|
||||||
|
|
||||||
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
|
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
|
||||||
MetaVarName<"symbol">;
|
MetaVarName<"symbol">;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue