2018-05-08 03:32:09 +08:00
|
|
|
include "llvm/Option/OptParser.td"
|
|
|
|
|
2018-11-02 01:20:40 +08:00
|
|
|
multiclass Eq<string name, string help> {
|
2018-11-02 05:38:14 +08:00
|
|
|
def NAME : Separate<["--", "-"], name>;
|
|
|
|
def NAME #_eq : Joined<["--", "-"], name #"=">,
|
|
|
|
Alias<!cast<Separate>(NAME)>,
|
|
|
|
HelpText<help>;
|
2018-05-08 03:32:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
def help : Flag<["-", "--"], "help">;
|
|
|
|
|
2018-11-02 01:36:37 +08:00
|
|
|
def enable_deterministic_archives
|
|
|
|
: Flag<["-", "--"], "enable-deterministic-archives">,
|
|
|
|
HelpText<"Enable deterministic mode when stripping archives (use zero "
|
|
|
|
"for UIDs, GIDs, and timestamps).">;
|
|
|
|
def D : Flag<["-"], "D">,
|
|
|
|
Alias<enable_deterministic_archives>,
|
|
|
|
HelpText<"Alias for --enable-deterministic-archives">;
|
|
|
|
|
|
|
|
def disable_deterministic_archives
|
|
|
|
: Flag<["-", "--"], "disable-deterministic-archives">,
|
|
|
|
HelpText<"Disable deterministic mode when stripping archives (use real "
|
|
|
|
"values for UIDs, GIDs, and timestamps).">;
|
|
|
|
def U : Flag<["-"], "U">,
|
|
|
|
Alias<disable_deterministic_archives>,
|
|
|
|
HelpText<"Alias for --disable-deterministic-archives">;
|
|
|
|
|
2018-11-02 05:38:14 +08:00
|
|
|
defm output : Eq<"o", "Write output to <file>">, MetaVarName<"output">;
|
2018-06-01 04:42:13 +08:00
|
|
|
|
2018-11-02 05:38:14 +08:00
|
|
|
def preserve_dates : Flag<["-", "--"], "preserve-dates">,
|
2018-08-17 02:29:40 +08:00
|
|
|
HelpText<"Preserve access and modification timestamps">;
|
2018-11-02 05:38:14 +08:00
|
|
|
def p : Flag<["-"], "p">, Alias<preserve_dates>;
|
2018-08-17 02:29:40 +08:00
|
|
|
|
2018-11-02 05:38:14 +08:00
|
|
|
def strip_all
|
|
|
|
: Flag<["-", "--"], "strip-all">,
|
|
|
|
HelpText<
|
|
|
|
"Remove non-allocated sections other than .gnu.warning* sections">;
|
|
|
|
def s : Flag<["-"], "s">, Alias<strip_all>;
|
[llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy case sensitive to support both -s (--strip-all) and -S (--strip-debug).
Summary:
GNU strip supports both `-s` and `-S` as aliases for `--strip-all` and `--strip-debug`, respectfully.
As part of this, it turns out that strip/objcopy were accepting case insensitive command line args. I'm not sure if there was an explicit reason for this. The only others uses of this are llvm-cvtres/llvm-mt/llvm-lib, which are all tools specific for windows support. Forcing case sensitivity allows both aliases to exist, but seems like a good idea anyway.
And as a surprise test case adjustment, the llvm-strip unit test was running with `-keep=unavailable_symbol`, despite `keep` not be a valid flag for strip. This is because there is a flag `-K` which, when case insensitivity is permitted, allows it to be interpreted as `-K` = `eep=unavailable_symbol` (e.g. to allow `-Kfoo` == `--keep-symbol=foo`).
Reviewers: jakehehrlich, jhenderson, alexshap
Reviewed By: jakehehrlich
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D53163
llvm-svn: 345068
2018-10-24 02:46:33 +08:00
|
|
|
|
2018-11-02 01:48:46 +08:00
|
|
|
def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
|
|
|
|
HelpText<"Compatible with GNU strip's --strip-all">;
|
2018-05-08 03:32:09 +08:00
|
|
|
def strip_debug : Flag<["-", "--"], "strip-debug">,
|
|
|
|
HelpText<"Remove debugging symbols only">;
|
2018-11-02 05:38:14 +08:00
|
|
|
def d : Flag<["-"], "d">, Alias<strip_debug>;
|
|
|
|
def g : Flag<["-"], "g">, Alias<strip_debug>;
|
|
|
|
def S : Flag<["-"], "S">, Alias<strip_debug>;
|
|
|
|
def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
|
|
|
|
HelpText<"Remove all symbols not needed by relocations">;
|
2018-06-05 02:55:41 +08:00
|
|
|
|
2018-11-02 01:20:40 +08:00
|
|
|
defm remove_section : Eq<"remove-section", "Remove <section>">,
|
|
|
|
MetaVarName<"section">;
|
2018-11-02 05:38:14 +08:00
|
|
|
def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>;
|
2018-05-24 03:44:19 +08:00
|
|
|
|
2019-01-31 20:16:20 +08:00
|
|
|
defm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
|
|
|
|
MetaVarName<"symbol">;
|
|
|
|
def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>;
|
|
|
|
|
[llvm-objcopy] Rename --keep to --keep-section.
Summary:
llvm-objcopy/strip support `--keep` (for sections) and `--keep-symbols` (for symbols). For consistency and clarity, rename `--keep` to `--keep-section`.
In fact, for GNU compatability, -K is --keep-symbol, so it's weird that the alias `-K` is not the same as the short-ish `--keep`.
Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola
Reviewed By: jakehehrlich, MaskRay
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D54477
llvm-svn: 346782
2018-11-14 03:32:27 +08:00
|
|
|
defm keep_section : Eq<"keep-section", "Keep <section>">,
|
|
|
|
MetaVarName<"section">;
|
2018-11-02 01:20:40 +08:00
|
|
|
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
|
|
|
|
MetaVarName<"symbol">;
|
2019-02-01 23:25:15 +08:00
|
|
|
def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
|
|
|
|
HelpText<"Do not remove file symbols">;
|
|
|
|
|
2018-11-02 05:38:14 +08:00
|
|
|
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
|
2018-05-24 03:44:19 +08:00
|
|
|
|
[llvm-objcopy] Support -X|--discard-locals.
Summary:
This adds support for the --discard-locals flag, which acts similarly to --discard-all, except it only applies to compiler-generated symbols (i.e. symbols starting with `.L` in ELF).
I am not sure about COFF local symbols: those appear to also use `.L` in most cases, but also use just `L` in other cases, so for now I am just leaving it unimplemented there.
Fixes PR36160
Reviewers: jhenderson, alexshap, jakehehrlich, mstorsjo, espindola
Reviewed By: jhenderson
Subscribers: llvm-commits, emaste, arichardson
Differential Revision: https://reviews.llvm.org/D57248
llvm-svn: 352626
2019-01-30 22:58:13 +08:00
|
|
|
def discard_locals : Flag<["-", "--"], "discard-locals">,
|
|
|
|
HelpText<"Remove compiler-generated local symbols, (e.g. "
|
|
|
|
"symbols starting with .L)">;
|
|
|
|
def X : Flag<["-"], "X">, Alias<discard_locals>;
|
|
|
|
|
2018-11-02 05:38:14 +08:00
|
|
|
def discard_all
|
|
|
|
: Flag<["-", "--"], "discard-all">,
|
|
|
|
HelpText<"Remove all local symbols except file and section symbols">;
|
|
|
|
def x : Flag<["-"], "x">, Alias<discard_all>;
|
2018-09-21 08:47:31 +08:00
|
|
|
|
2018-11-02 05:38:14 +08:00
|
|
|
def version : Flag<["-", "--"], "version">,
|
2018-09-21 08:47:31 +08:00
|
|
|
HelpText<"Print the version and exit.">;
|
2018-11-28 14:51:50 +08:00
|
|
|
def V : Flag<["-"], "V">, Alias<version>;
|