forked from OSchip/llvm-project
[llvm-strip] Expose --strip-unneeded option
Differential Revision: https://reviews.llvm.org/D47818 llvm-svn: 334182
This commit is contained in:
parent
e1d18758eb
commit
e57bc78324
|
@ -1,7 +1,14 @@
|
||||||
# RUN: yaml2obj %s > %t
|
# RUN: yaml2obj %s > %t
|
||||||
|
# RUN: cp %t %t1
|
||||||
# RUN: llvm-objcopy --strip-unneeded %t %t2
|
# RUN: llvm-objcopy --strip-unneeded %t %t2
|
||||||
|
# Verify that llvm-objcopy has not modified the input.
|
||||||
|
# RUN: cmp %t %t1
|
||||||
# RUN: llvm-readobj -symbols %t2 | FileCheck %s
|
# RUN: llvm-readobj -symbols %t2 | FileCheck %s
|
||||||
|
|
||||||
|
# Verify that llvm-strip modifies the symbol table the same way.
|
||||||
|
# RUN: llvm-strip --strip-unneeded %t
|
||||||
|
# RUN: cmp %t %t2
|
||||||
|
|
||||||
!ELF
|
!ELF
|
||||||
FileHeader:
|
FileHeader:
|
||||||
Class: ELFCLASS64
|
Class: ELFCLASS64
|
||||||
|
|
|
@ -41,3 +41,6 @@ def discard_all : Flag<["-", "--"], "discard-all">,
|
||||||
HelpText<"Remove all local symbols except file and section symbols">;
|
HelpText<"Remove all local symbols except file and section symbols">;
|
||||||
def x : Flag<["-"], "x">,
|
def x : Flag<["-"], "x">,
|
||||||
Alias<discard_all>;
|
Alias<discard_all>;
|
||||||
|
|
||||||
|
def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
|
||||||
|
HelpText<"Remove all symbols not needed by relocations">;
|
||||||
|
|
|
@ -583,12 +583,12 @@ CopyConfig ParseStripOptions(ArrayRef<const char *> ArgsArr) {
|
||||||
Config.OutputFilename =
|
Config.OutputFilename =
|
||||||
InputArgs.getLastArgValue(STRIP_output, Positional[0]);
|
InputArgs.getLastArgValue(STRIP_output, Positional[0]);
|
||||||
|
|
||||||
// Strip debug info only.
|
|
||||||
Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
|
Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);
|
||||||
|
|
||||||
Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
|
Config.DiscardAll = InputArgs.hasArg(STRIP_discard_all);
|
||||||
|
Config.StripUnneeded = InputArgs.hasArg(STRIP_strip_unneeded);
|
||||||
if (!Config.StripDebug && !Config.DiscardAll)
|
|
||||||
|
if (!Config.StripDebug && !Config.StripUnneeded && !Config.DiscardAll)
|
||||||
Config.StripAll = true;
|
Config.StripAll = true;
|
||||||
|
|
||||||
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
|
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
|
||||||
|
|
Loading…
Reference in New Issue