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