xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-objcopy/CommonOpts.td (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1include "llvm/Option/OptParser.td"
2
3multiclass Eq<string name, string help> {
4  def NAME : Separate<["--"], name>;
5  def NAME #_eq : Joined<["--"], name #"=">,
6                  Alias<!cast<Separate>(NAME)>,
7                  HelpText<help>;
8}
9
10def grp_coff : OptionGroup<"kind">, HelpText<"OPTIONS (COFF specific)">;
11def grp_macho : OptionGroup<"kind">, HelpText<"OPTIONS (Mach-O specific)">;
12
13def help : Flag<["--"], "help">;
14def h : Flag<["-"], "h">, Alias<help>;
15
16def allow_broken_links
17    : Flag<["--"], "allow-broken-links">,
18      HelpText<"Allow the tool to remove sections even if it would leave "
19               "invalid section references. The appropriate sh_link fields "
20               "will be set to zero.">;
21
22def enable_deterministic_archives
23    : Flag<["--"], "enable-deterministic-archives">,
24      HelpText<"Enable deterministic mode when operating on archives (use "
25               "zero for UIDs, GIDs, and timestamps).">;
26def D : Flag<["-"], "D">,
27        Alias<enable_deterministic_archives>,
28        HelpText<"Alias for --enable-deterministic-archives">;
29
30def disable_deterministic_archives
31    : Flag<["--"], "disable-deterministic-archives">,
32      HelpText<"Disable deterministic mode when operating on archives (use "
33               "real values for UIDs, GIDs, and timestamps).">;
34def U : Flag<["-"], "U">,
35        Alias<disable_deterministic_archives>,
36        HelpText<"Alias for --disable-deterministic-archives">;
37
38def preserve_dates : Flag<["--"], "preserve-dates">,
39                     HelpText<"Preserve access and modification timestamps">;
40def p : Flag<["-"], "p">,
41        Alias<preserve_dates>,
42        HelpText<"Alias for --preserve-dates">;
43
44def strip_all : Flag<["--"], "strip-all">,
45    HelpText<"For ELF, remove all symbols and non-alloc sections not within "
46             "segments, except for .gnu.warning*, .ARM.attribute, and the section name table. "
47             "For COFF and Mach-O, remove all symbols, debug sections, and relocations">;
48
49def strip_all_gnu
50    : Flag<["--"], "strip-all-gnu">,
51      HelpText<"Remove all symbols, debug sections and relocations. Compatible with GNU's --strip-all">;
52
53def strip_debug : Flag<["--"], "strip-debug">,
54                  HelpText<"Remove all debug sections">;
55def g : Flag<["-"], "g">,
56        Alias<strip_debug>,
57        HelpText<"Alias for --strip-debug">;
58
59def strip_unneeded : Flag<["--"], "strip-unneeded">,
60                     HelpText<"Remove all symbols not needed by relocations">;
61
62defm remove_section : Eq<"remove-section", "Remove <section>">,
63                      MetaVarName<"section">;
64def R : JoinedOrSeparate<["-"], "R">,
65        Alias<remove_section>,
66        HelpText<"Alias for --remove-section">;
67
68def strip_sections
69    : Flag<["--"], "strip-sections">,
70      HelpText<"Remove all section headers and all section data not within segments">;
71
72defm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
73                    MetaVarName<"symbol">;
74def N : JoinedOrSeparate<["-"], "N">,
75        Alias<strip_symbol>,
76        HelpText<"Alias for --strip-symbol">;
77
78defm keep_section : Eq<"keep-section", "Keep <section>">,
79                    MetaVarName<"section">;
80
81defm keep_symbol : Eq<"keep-symbol", "When removing symbols, do not remove <symbol>">,
82                   MetaVarName<"symbol">;
83def K : JoinedOrSeparate<["-"], "K">,
84        Alias<keep_symbol>,
85        HelpText<"Alias for --keep-symbol">;
86
87def keep_file_symbols : Flag<["--"], "keep-file-symbols">,
88                        HelpText<"Keep symbols of type STT_FILE, even if they would otherwise be stripped">;
89
90def keep_undefined : Flag<["--"], "keep-undefined">,
91                        HelpText<"Do not remove undefined symbols">, Group<grp_macho>;
92
93def only_keep_debug
94    : Flag<["--"], "only-keep-debug">,
95      HelpText<
96          "Produce a debug file as the output that only preserves contents of "
97          "sections useful for debugging purposes">;
98
99def discard_locals : Flag<["--"], "discard-locals">,
100                     HelpText<"Remove local symbols starting with .L">;
101def X : Flag<["-"], "X">,
102        Alias<discard_locals>,
103        HelpText<"Alias for --discard-locals">;
104
105def discard_all
106    : Flag<["--"], "discard-all">,
107      HelpText<"Remove most local symbols. Different file formats may limit this to a subset. "
108      "For ELF, file and section symbols are not discarded. "
109      "Additionally, remove all debug sections">;
110def x : Flag<["-"], "x">,
111        Alias<discard_all>,
112        HelpText<"Alias for --discard-all">;
113
114def regex
115    : Flag<["--"], "regex">,
116      HelpText<"Permit regular expressions in name comparison">;
117
118def version : Flag<["--"], "version">,
119              HelpText<"Print the version and exit.">;
120def V : Flag<["-"], "V">,
121        Alias<version>,
122        HelpText<"Alias for --version">;
123
124def wildcard
125    : Flag<["--"], "wildcard">,
126      HelpText<"Allow wildcard syntax for symbol-related flags. Incompatible "
127               "with --regex. Allows using '*' to match any number of "
128               "characters, '?' to match any single character, '\' to escape "
129               "special characters, and '[]' to define character classes. "
130               "Wildcards beginning with '!' will prevent a match, for example "
131               "\"-N '*' -N '!x'\" will strip all symbols except for \"x\".">;
132def w : Flag<["-"], "w">, Alias<wildcard>, HelpText<"Alias for --wildcard">;
133