blob: b8fbe74fa1362c5ff25ad41af10df243bd15674c [file] [log] [blame]
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +00001include "llvm/Option/OptParser.td"
2
Fangrui Songab205a32018-11-01 17:20:40 +00003multiclass Eq<string name, string help> {
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +00004 def NAME : Separate<["--", "-"], name>;
5 def NAME #_eq : Joined<["--", "-"], name #"=">,
6 Alias<!cast<Separate>(NAME)>,
7 HelpText<help>;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +00008}
9
10def help : Flag<["-", "--"], "help">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000011
Fangrui Songab205a32018-11-01 17:20:40 +000012defm binary_architecture
13 : Eq<"binary-architecture", "Used when transforming an architecture-less "
14 "format (such as binary) to another format">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000015def B : JoinedOrSeparate<["-"], "B">, Alias<binary_architecture>;
16
Fangrui Songab205a32018-11-01 17:20:40 +000017defm target : Eq<"target", "Format of the input and output file">,
Jordan Rupprechtbb4588e2018-10-12 00:36:01 +000018 Values<"binary">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000019def F : JoinedOrSeparate<["-"], "F">, Alias<target>;
20
Fangrui Songab205a32018-11-01 17:20:40 +000021defm input_target : Eq<"input-target", "Format of the input file">,
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000022 Values<"binary">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000023def I : JoinedOrSeparate<["-"], "I">, Alias<input_target>;
24
Fangrui Songab205a32018-11-01 17:20:40 +000025defm output_target : Eq<"output-target", "Format of the output file">,
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000026 Values<"binary">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000027def O : JoinedOrSeparate<["-"], "O">, Alias<output_target>;
28
Puyan Lotfi99124cc2018-09-07 08:10:22 +000029def compress_debug_sections : Flag<["--", "-"], "compress-debug-sections">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000030def compress_debug_sections_eq
31 : Joined<["--", "-"], "compress-debug-sections=">,
32 MetaVarName<"[ zlib | zlib-gnu ]">,
33 HelpText<"Compress DWARF debug sections using specified style. Supported "
34 "styles: 'zlib-gnu' and 'zlib'">;
Puyan Lotfiaf048642018-10-01 10:29:41 +000035def decompress_debug_sections : Flag<["-", "--"], "decompress-debug-sections">,
36 HelpText<"Decompress DWARF debug sections.">;
Fangrui Songab205a32018-11-01 17:20:40 +000037defm split_dwo
38 : Eq<"split-dwo", "Equivalent to extract-dwo on the input file to "
39 "<dwo-file>, then strip-dwo on the input file">,
40 MetaVarName<"dwo-file">;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000041
Jordan Rupprechtfc780bb2018-11-01 17:36:37 +000042def enable_deterministic_archives
43 : Flag<["-", "--"], "enable-deterministic-archives">,
44 HelpText<"Enable deterministic mode when copying archives (use zero for "
45 "UIDs, GIDs, and timestamps).">;
46def D : Flag<["-"], "D">,
47 Alias<enable_deterministic_archives>,
48 HelpText<"Alias for --enable-deterministic-archives">;
49
50def disable_deterministic_archives
51 : Flag<["-", "--"], "disable-deterministic-archives">,
52 HelpText<"Disable deterministic mode when copying archives (use real "
53 "values for UIDs, GIDs, and timestamps).">;
54def U : Flag<["-"], "U">,
55 Alias<disable_deterministic_archives>,
56 HelpText<"Alias for --disable-deterministic-archives">;
57
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000058def preserve_dates : Flag<["-", "--"], "preserve-dates">,
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000059 HelpText<"Preserve access and modification timestamps">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000060def p : Flag<["-"], "p">, Alias<preserve_dates>;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000061
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000062defm add_gnu_debuglink
63 : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">,
64 MetaVarName<"debug-file">;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000065
Fangrui Songab205a32018-11-01 17:20:40 +000066defm remove_section : Eq<"remove-section", "Remove <section>">,
67 MetaVarName<"section">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000068def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>;
69
Jordan Rupprechtd67c1e12018-08-01 16:23:22 +000070defm rename_section
Fangrui Songab205a32018-11-01 17:20:40 +000071 : Eq<"rename-section",
72 "Renames a section from old to new, optionally with specified flags. "
73 "Flags supported for GNU compatibility: alloc, load, noload, "
74 "readonly, debug, code, data, rom, share, contents, merge, strings.">,
75 MetaVarName<"old=new[,flag1,...]">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000076defm redefine_symbol
77 : Eq<"redefine-sym", "Change the name of a symbol old to new">,
78 MetaVarName<"old=new">;
Eugene Leviant340cb872019-02-08 10:33:16 +000079defm redefine_symbols
80 : Eq<"redefine-syms",
81 "Reads a list of symbol pairs from <filename> and runs as if "
82 "--redefine-sym=<old>=<new> is set for each one. <filename> "
83 "contains two symbols per line separated with whitespace and may "
84 "contain comments beginning with '#'. Leading and trailing "
85 "whitespace is stripped from each line. May be repeated to read "
86 "symbols from many files.">,
87 MetaVarName<"filename">;
88
Jordan Rupprechtc5bae782018-11-13 19:32:27 +000089defm keep_section : Eq<"keep-section", "Keep <section>">,
90 MetaVarName<"section">;
Jake Ehrlich85985ed2018-12-06 02:03:53 +000091defm only_section : Eq<"only-section", "Remove all but <section>">,
92 MetaVarName<"section">;
93def j : JoinedOrSeparate<["-"], "j">, Alias<only_section>;
Fangrui Songab205a32018-11-01 17:20:40 +000094defm add_section
95 : Eq<"add-section",
96 "Make a section named <section> with the contents of <file>.">,
97 MetaVarName<"section=file">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000098
Jordan Rupprechtc8927412019-01-29 15:05:38 +000099defm set_section_flags
100 : Eq<"set-section-flags",
101 "Set section flags for a given section. Flags supported for GNU "
102 "compatibility: alloc, load, noload, readonly, debug, code, data, "
103 "rom, share, contents, merge, strings.">,
104 MetaVarName<"section=flag1[,flag2,...]">;
105
James Hendersonb5de5e22019-03-14 11:47:41 +0000106def strip_all : Flag<["-", "--"], "strip-all">,
107 HelpText<"Remove non-allocated sections outside segments. "
108 ".gnu.warning* sections are not removed">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000109def S : Flag<["-"], "S">, Alias<strip_all>;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +0000110def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
Jordan Rupprecht30d1b192018-11-01 17:48:46 +0000111 HelpText<"Compatible with GNU objcopy's --strip-all">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +0000112def strip_debug : Flag<["-", "--"], "strip-debug">,
Alexander Shaposhnikovb3bfd3b2018-04-24 21:44:13 +0000113 HelpText<"Remove all debug information">;
Douglas Yung914e8382019-01-25 09:57:20 +0000114def g : Flag<["-"], "g">, Alias<strip_debug>,
115 HelpText<"Alias for --strip-debug">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +0000116def strip_dwo : Flag<["-", "--"], "strip-dwo">,
117 HelpText<"Remove all DWARF .dwo sections from file">;
James Hendersonb5de5e22019-03-14 11:47:41 +0000118def strip_sections
119 : Flag<["-", "--"], "strip-sections">,
120 HelpText<"Remove all section headers and all sections not in segments">;
121def strip_non_alloc
122 : Flag<["-", "--"], "strip-non-alloc">,
123 HelpText<"Remove all non-allocated sections outside segments">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000124def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
125 HelpText<"Remove all symbols not needed by relocations">;
James Hendersonb5de5e22019-03-14 11:47:41 +0000126defm strip_unneeded_symbol
Eugene Leviant2db10622019-02-13 07:34:54 +0000127 : Eq<"strip-unneeded-symbol",
128 "Remove symbol <symbol> if it is not needed by relocations">,
129 MetaVarName<"symbol">;
130defm strip_unneeded_symbols
131 : Eq<"strip-unneeded-symbols",
132 "Reads a list of symbols from <filename> and removes them "
133 "if they are not needed by relocations">,
134 MetaVarName<"filename">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000135
136def extract_dwo
137 : Flag<["-", "--"], "extract-dwo">,
138 HelpText<
139 "Remove all sections that are not DWARF .dwo sections from file">;
140
141def localize_hidden
142 : Flag<["-", "--"], "localize-hidden">,
143 HelpText<
144 "Mark all symbols that have hidden or internal visibility as local">;
Fangrui Songab205a32018-11-01 17:20:40 +0000145defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">,
146 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000147defm localize_symbols
148 : Eq<"localize-symbols",
149 "Reads a list of symbols from <filename> and marks them local.">,
150 MetaVarName<"filename">;
151
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000152def L : JoinedOrSeparate<["-"], "L">, Alias<localize_symbol>;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000153
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000154defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
155 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000156
157defm globalize_symbols
158 : Eq<"globalize-symbols",
159 "Reads a list of symbols from <filename> and marks them global.">,
160 MetaVarName<"filename">;
161
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000162defm keep_global_symbol
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000163 : Eq<"keep-global-symbol",
164 "Convert all symbols except <symbol> to local. May be repeated to "
165 "convert all except a set of symbols to local.">,
Fangrui Songab205a32018-11-01 17:20:40 +0000166 MetaVarName<"symbol">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000167def G : JoinedOrSeparate<["-"], "G">, Alias<keep_global_symbol>;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000168
169defm keep_global_symbols
Fangrui Songab205a32018-11-01 17:20:40 +0000170 : Eq<"keep-global-symbols",
171 "Reads a list of symbols from <filename> and runs as if "
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000172 "--keep-global-symbol=<symbol> is set for each one. <filename> "
173 "contains one symbol per line and may contain comments beginning with "
174 "'#'. Leading and trailing whitespace is stripped from each line. May "
175 "be repeated to read symbols from many files.">,
Fangrui Songab205a32018-11-01 17:20:40 +0000176 MetaVarName<"filename">;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000177
Fangrui Songab205a32018-11-01 17:20:40 +0000178defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000179 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000180defm weaken_symbols
181 : Eq<"weaken-symbols",
182 "Reads a list of symbols from <filename> and marks them weak.">,
183 MetaVarName<"filename">;
184
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000185def W : JoinedOrSeparate<["-"], "W">, Alias<weaken_symbol>;
Paul Semel2c0510f2018-05-02 20:14:49 +0000186def weaken : Flag<["-", "--"], "weaken">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000187 HelpText<"Mark all global symbols as weak">;
Jordan Rupprechtd0f7bcf2019-01-30 14:58:13 +0000188
189def discard_locals : Flag<["-", "--"], "discard-locals">,
190 HelpText<"Remove compiler-generated local symbols, (e.g. "
191 "symbols starting with .L)">;
192def X : Flag<["-"], "X">, Alias<discard_locals>;
193
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000194def discard_all
195 : Flag<["-", "--"], "discard-all">,
196 HelpText<"Remove all local symbols except file and section symbols">;
197def x : Flag<["-"], "x">, Alias<discard_all>;
Fangrui Songab205a32018-11-01 17:20:40 +0000198defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000199 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000200defm strip_symbols
201 : Eq<"strip-symbols",
202 "Reads a list of symbols from <filename> and removes them.">,
203 MetaVarName<"filename">;
204
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000205def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>;
Fangrui Songab205a32018-11-01 17:20:40 +0000206defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000207 MetaVarName<"symbol">;
208def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
Jordan Rupprecht12ed01d2019-03-14 21:51:42 +0000209
Yi Kongf2baddb2019-04-01 18:12:43 +0000210defm keep_symbols
211 : Eq<"keep-symbols",
212 "Reads a list of symbols from <filename> and runs as if "
213 "--keep-symbol=<symbol> is set for each one. <filename> "
214 "contains one symbol per line and may contain comments beginning with "
215 "'#'. Leading and trailing whitespace is stripped from each line. May "
216 "be repeated to read symbols from many files.">,
217 MetaVarName<"filename">;
218
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000219def only_keep_debug
220 : Flag<["-", "--"], "only-keep-debug">,
Jordan Rupprecht12ed01d2019-03-14 21:51:42 +0000221 HelpText<"Clear sections that would not be stripped by --strip-debug. "
222 "Currently only implemented for COFF.">;
223
Paul Semelcf51c802018-05-26 08:10:37 +0000224def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000225 HelpText<"Do not remove file symbols">;
226defm dump_section
227 : Eq<"dump-section",
228 "Dump contents of section named <section> into file <file>">,
229 MetaVarName<"section=file">;
230defm prefix_symbols
231 : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">,
232 MetaVarName<"prefix">;
233
234def version : Flag<["-", "--"], "version">,
235 HelpText<"Print the version and exit.">;
Martin Storsjoe9af7152018-11-28 06:51:50 +0000236def V : Flag<["-"], "V">, Alias<version>;
Jake Ehrlich8ad77792018-12-03 19:49:23 +0000237defm build_id_link_dir
238 : Eq<"build-id-link-dir", "Set directory for --build-id-link-input and "
239 "--build-id-link-output to <dir>">,
240 MetaVarName<"dir">;
241defm build_id_link_input
242 : Eq<"build-id-link-input", "Hard-link the input to <dir>/xx/xxx<suffix> "
243 "name derived from hex build ID">,
244 MetaVarName<"suffix">;
245defm build_id_link_output
246 : Eq<"build-id-link-output", "Hard-link the output to <dir>/xx/xxx<suffix> "
247 "name derived from hex build ID">,
248 MetaVarName<"suffix">;
Eugene Leviantf324f6d2019-02-06 11:00:07 +0000249
250def regex
251 : Flag<["-", "--"], "regex">,
252 HelpText<"Permit regular expressions in name comparison">;
Eugene Leviant51c1f642019-02-25 14:12:41 +0000253
Eugene Leviant53350d02019-02-26 09:24:22 +0000254defm set_start : Eq<"set-start", "Set the start address to <addr>. Overrides "
255 "any previous --change-start or --adjust-start values.">,
256 MetaVarName<"addr">;
257defm change_start : Eq<"change-start", "Add <incr> to the start address. Can be "
258 "specified multiple times, all values will be applied "
259 "cumulatively.">,
260 MetaVarName<"incr">;
261def adjust_start : JoinedOrSeparate<["-", "--"], "adjust-start">,
262 Alias<change_start>;
263
Eugene Leviant51c1f642019-02-25 14:12:41 +0000264defm add_symbol
265 : Eq<"add-symbol", "Add new symbol <name> to .symtab. Accepted flags: "
266 "global, local, weak, default, hidden, file, section, object, "
267 "function, indirect-function. Accepted but ignored for "
268 "compatibility: debug, constructor, warning, indirect, synthetic, "
269 "unique-object, before.">,
270 MetaVarName<"name=[section:]value[,flags]">;