blob: bf3a1dcfc2f596689efbea3b4d5cc1bfac29d8e0 [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
James Henderson66a9d0f2019-04-18 09:13:30 +000012def allow_broken_links
13 : Flag<["-", "--"], "allow-broken-links">,
14 HelpText<"Allow llvm-objcopy to remove sections even if it would leave "
15 "invalid section references. The appropriate sh_link fields"
16 "will be set to zero.">;
17
Fangrui Songab205a32018-11-01 17:20:40 +000018defm binary_architecture
19 : Eq<"binary-architecture", "Used when transforming an architecture-less "
20 "format (such as binary) to another format">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000021def B : JoinedOrSeparate<["-"], "B">, Alias<binary_architecture>;
22
Fangrui Songab205a32018-11-01 17:20:40 +000023defm target : Eq<"target", "Format of the input and output file">,
Jordan Rupprechtbb4588e2018-10-12 00:36:01 +000024 Values<"binary">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000025def F : JoinedOrSeparate<["-"], "F">, Alias<target>;
26
Fangrui Songab205a32018-11-01 17:20:40 +000027defm input_target : Eq<"input-target", "Format of the input file">,
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000028 Values<"binary">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000029def I : JoinedOrSeparate<["-"], "I">, Alias<input_target>;
30
Fangrui Songab205a32018-11-01 17:20:40 +000031defm output_target : Eq<"output-target", "Format of the output file">,
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000032 Values<"binary">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000033def O : JoinedOrSeparate<["-"], "O">, Alias<output_target>;
34
Puyan Lotfi99124cc2018-09-07 08:10:22 +000035def compress_debug_sections : Flag<["--", "-"], "compress-debug-sections">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000036def compress_debug_sections_eq
37 : Joined<["--", "-"], "compress-debug-sections=">,
38 MetaVarName<"[ zlib | zlib-gnu ]">,
39 HelpText<"Compress DWARF debug sections using specified style. Supported "
40 "styles: 'zlib-gnu' and 'zlib'">;
Puyan Lotfiaf048642018-10-01 10:29:41 +000041def decompress_debug_sections : Flag<["-", "--"], "decompress-debug-sections">,
42 HelpText<"Decompress DWARF debug sections.">;
Fangrui Songab205a32018-11-01 17:20:40 +000043defm split_dwo
44 : Eq<"split-dwo", "Equivalent to extract-dwo on the input file to "
45 "<dwo-file>, then strip-dwo on the input file">,
46 MetaVarName<"dwo-file">;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000047
Jordan Rupprechtfc780bb2018-11-01 17:36:37 +000048def enable_deterministic_archives
49 : Flag<["-", "--"], "enable-deterministic-archives">,
50 HelpText<"Enable deterministic mode when copying archives (use zero for "
51 "UIDs, GIDs, and timestamps).">;
52def D : Flag<["-"], "D">,
53 Alias<enable_deterministic_archives>,
54 HelpText<"Alias for --enable-deterministic-archives">;
55
56def disable_deterministic_archives
57 : Flag<["-", "--"], "disable-deterministic-archives">,
58 HelpText<"Disable deterministic mode when copying archives (use real "
59 "values for UIDs, GIDs, and timestamps).">;
60def U : Flag<["-"], "U">,
61 Alias<disable_deterministic_archives>,
62 HelpText<"Alias for --disable-deterministic-archives">;
63
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000064def preserve_dates : Flag<["-", "--"], "preserve-dates">,
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000065 HelpText<"Preserve access and modification timestamps">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000066def p : Flag<["-"], "p">, Alias<preserve_dates>;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000067
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000068defm add_gnu_debuglink
69 : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">,
70 MetaVarName<"debug-file">;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000071
Fangrui Songab205a32018-11-01 17:20:40 +000072defm remove_section : Eq<"remove-section", "Remove <section>">,
73 MetaVarName<"section">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000074def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>;
75
Jordan Rupprechtd67c1e12018-08-01 16:23:22 +000076defm rename_section
Fangrui Songab205a32018-11-01 17:20:40 +000077 : Eq<"rename-section",
78 "Renames a section from old to new, optionally with specified flags. "
79 "Flags supported for GNU compatibility: alloc, load, noload, "
80 "readonly, debug, code, data, rom, share, contents, merge, strings.">,
81 MetaVarName<"old=new[,flag1,...]">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +000082defm redefine_symbol
83 : Eq<"redefine-sym", "Change the name of a symbol old to new">,
84 MetaVarName<"old=new">;
Eugene Leviant340cb872019-02-08 10:33:16 +000085defm redefine_symbols
86 : Eq<"redefine-syms",
87 "Reads a list of symbol pairs from <filename> and runs as if "
88 "--redefine-sym=<old>=<new> is set for each one. <filename> "
89 "contains two symbols per line separated with whitespace and may "
90 "contain comments beginning with '#'. Leading and trailing "
91 "whitespace is stripped from each line. May be repeated to read "
92 "symbols from many files.">,
93 MetaVarName<"filename">;
94
Jordan Rupprechtc5bae782018-11-13 19:32:27 +000095defm keep_section : Eq<"keep-section", "Keep <section>">,
96 MetaVarName<"section">;
Jake Ehrlich85985ed2018-12-06 02:03:53 +000097defm only_section : Eq<"only-section", "Remove all but <section>">,
98 MetaVarName<"section">;
99def j : JoinedOrSeparate<["-"], "j">, Alias<only_section>;
Fangrui Songab205a32018-11-01 17:20:40 +0000100defm add_section
101 : Eq<"add-section",
102 "Make a section named <section> with the contents of <file>.">,
103 MetaVarName<"section=file">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000104
Jordan Rupprechtc8927412019-01-29 15:05:38 +0000105defm set_section_flags
106 : Eq<"set-section-flags",
107 "Set section flags for a given section. Flags supported for GNU "
108 "compatibility: alloc, load, noload, readonly, debug, code, data, "
109 "rom, share, contents, merge, strings.">,
110 MetaVarName<"section=flag1[,flag2,...]">;
111
James Hendersonb5de5e22019-03-14 11:47:41 +0000112def strip_all : Flag<["-", "--"], "strip-all">,
113 HelpText<"Remove non-allocated sections outside segments. "
114 ".gnu.warning* sections are not removed">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000115def S : Flag<["-"], "S">, Alias<strip_all>;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +0000116def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
Jordan Rupprecht30d1b192018-11-01 17:48:46 +0000117 HelpText<"Compatible with GNU objcopy's --strip-all">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +0000118def strip_debug : Flag<["-", "--"], "strip-debug">,
Alexander Shaposhnikovb3bfd3b2018-04-24 21:44:13 +0000119 HelpText<"Remove all debug information">;
Douglas Yung914e8382019-01-25 09:57:20 +0000120def g : Flag<["-"], "g">, Alias<strip_debug>,
121 HelpText<"Alias for --strip-debug">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +0000122def strip_dwo : Flag<["-", "--"], "strip-dwo">,
123 HelpText<"Remove all DWARF .dwo sections from file">;
James Hendersonb5de5e22019-03-14 11:47:41 +0000124def strip_sections
125 : Flag<["-", "--"], "strip-sections">,
126 HelpText<"Remove all section headers and all sections not in segments">;
127def strip_non_alloc
128 : Flag<["-", "--"], "strip-non-alloc">,
129 HelpText<"Remove all non-allocated sections outside segments">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000130def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
131 HelpText<"Remove all symbols not needed by relocations">;
James Hendersonb5de5e22019-03-14 11:47:41 +0000132defm strip_unneeded_symbol
Eugene Leviant2db10622019-02-13 07:34:54 +0000133 : Eq<"strip-unneeded-symbol",
134 "Remove symbol <symbol> if it is not needed by relocations">,
135 MetaVarName<"symbol">;
136defm strip_unneeded_symbols
137 : Eq<"strip-unneeded-symbols",
138 "Reads a list of symbols from <filename> and removes them "
139 "if they are not needed by relocations">,
140 MetaVarName<"filename">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000141
142def extract_dwo
143 : Flag<["-", "--"], "extract-dwo">,
144 HelpText<
145 "Remove all sections that are not DWARF .dwo sections from file">;
146
147def localize_hidden
148 : Flag<["-", "--"], "localize-hidden">,
149 HelpText<
150 "Mark all symbols that have hidden or internal visibility as local">;
Fangrui Songab205a32018-11-01 17:20:40 +0000151defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">,
152 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000153defm localize_symbols
154 : Eq<"localize-symbols",
155 "Reads a list of symbols from <filename> and marks them local.">,
156 MetaVarName<"filename">;
157
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000158def L : JoinedOrSeparate<["-"], "L">, Alias<localize_symbol>;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000159
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000160defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
161 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000162
163defm globalize_symbols
164 : Eq<"globalize-symbols",
165 "Reads a list of symbols from <filename> and marks them global.">,
166 MetaVarName<"filename">;
167
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000168defm keep_global_symbol
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000169 : Eq<"keep-global-symbol",
170 "Convert all symbols except <symbol> to local. May be repeated to "
171 "convert all except a set of symbols to local.">,
Fangrui Songab205a32018-11-01 17:20:40 +0000172 MetaVarName<"symbol">;
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000173def G : JoinedOrSeparate<["-"], "G">, Alias<keep_global_symbol>;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000174
175defm keep_global_symbols
Fangrui Songab205a32018-11-01 17:20:40 +0000176 : Eq<"keep-global-symbols",
177 "Reads a list of symbols from <filename> and runs as if "
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000178 "--keep-global-symbol=<symbol> is set for each one. <filename> "
179 "contains one symbol per line and may contain comments beginning with "
180 "'#'. Leading and trailing whitespace is stripped from each line. May "
181 "be repeated to read symbols from many files.">,
Fangrui Songab205a32018-11-01 17:20:40 +0000182 MetaVarName<"filename">;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000183
Fangrui Songab205a32018-11-01 17:20:40 +0000184defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000185 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000186defm weaken_symbols
187 : Eq<"weaken-symbols",
188 "Reads a list of symbols from <filename> and marks them weak.">,
189 MetaVarName<"filename">;
190
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000191def W : JoinedOrSeparate<["-"], "W">, Alias<weaken_symbol>;
Paul Semel2c0510f2018-05-02 20:14:49 +0000192def weaken : Flag<["-", "--"], "weaken">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000193 HelpText<"Mark all global symbols as weak">;
Jordan Rupprechtd0f7bcf2019-01-30 14:58:13 +0000194
195def discard_locals : Flag<["-", "--"], "discard-locals">,
196 HelpText<"Remove compiler-generated local symbols, (e.g. "
197 "symbols starting with .L)">;
198def X : Flag<["-"], "X">, Alias<discard_locals>;
199
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000200def discard_all
201 : Flag<["-", "--"], "discard-all">,
202 HelpText<"Remove all local symbols except file and section symbols">;
203def x : Flag<["-"], "x">, Alias<discard_all>;
Fangrui Songab205a32018-11-01 17:20:40 +0000204defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000205 MetaVarName<"symbol">;
Eugene Leviante08fe352019-02-08 14:37:54 +0000206defm strip_symbols
207 : Eq<"strip-symbols",
208 "Reads a list of symbols from <filename> and removes them.">,
209 MetaVarName<"filename">;
210
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000211def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>;
Fangrui Songab205a32018-11-01 17:20:40 +0000212defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000213 MetaVarName<"symbol">;
214def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
Jordan Rupprecht12ed01d2019-03-14 21:51:42 +0000215
Yi Kongf2baddb2019-04-01 18:12:43 +0000216defm keep_symbols
217 : Eq<"keep-symbols",
218 "Reads a list of symbols from <filename> and runs as if "
219 "--keep-symbol=<symbol> is set for each one. <filename> "
220 "contains one symbol per line and may contain comments beginning with "
221 "'#'. Leading and trailing whitespace is stripped from each line. May "
222 "be repeated to read symbols from many files.">,
223 MetaVarName<"filename">;
224
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000225def only_keep_debug
226 : Flag<["-", "--"], "only-keep-debug">,
Jordan Rupprecht12ed01d2019-03-14 21:51:42 +0000227 HelpText<"Clear sections that would not be stripped by --strip-debug. "
228 "Currently only implemented for COFF.">;
229
Paul Semelcf51c802018-05-26 08:10:37 +0000230def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
Jordan Rupprecht56c0ee02018-11-01 21:38:14 +0000231 HelpText<"Do not remove file symbols">;
232defm dump_section
233 : Eq<"dump-section",
234 "Dump contents of section named <section> into file <file>">,
235 MetaVarName<"section=file">;
236defm prefix_symbols
237 : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">,
238 MetaVarName<"prefix">;
239
240def version : Flag<["-", "--"], "version">,
241 HelpText<"Print the version and exit.">;
Martin Storsjoe9af7152018-11-28 06:51:50 +0000242def V : Flag<["-"], "V">, Alias<version>;
Jake Ehrlich8ad77792018-12-03 19:49:23 +0000243defm build_id_link_dir
244 : Eq<"build-id-link-dir", "Set directory for --build-id-link-input and "
245 "--build-id-link-output to <dir>">,
246 MetaVarName<"dir">;
247defm build_id_link_input
248 : Eq<"build-id-link-input", "Hard-link the input to <dir>/xx/xxx<suffix> "
249 "name derived from hex build ID">,
250 MetaVarName<"suffix">;
251defm build_id_link_output
252 : Eq<"build-id-link-output", "Hard-link the output to <dir>/xx/xxx<suffix> "
253 "name derived from hex build ID">,
254 MetaVarName<"suffix">;
Eugene Leviantf324f6d2019-02-06 11:00:07 +0000255
256def regex
257 : Flag<["-", "--"], "regex">,
258 HelpText<"Permit regular expressions in name comparison">;
Eugene Leviant51c1f642019-02-25 14:12:41 +0000259
Eugene Leviant53350d02019-02-26 09:24:22 +0000260defm set_start : Eq<"set-start", "Set the start address to <addr>. Overrides "
261 "any previous --change-start or --adjust-start values.">,
262 MetaVarName<"addr">;
263defm change_start : Eq<"change-start", "Add <incr> to the start address. Can be "
264 "specified multiple times, all values will be applied "
265 "cumulatively.">,
266 MetaVarName<"incr">;
267def adjust_start : JoinedOrSeparate<["-", "--"], "adjust-start">,
268 Alias<change_start>;
269
Eugene Leviant51c1f642019-02-25 14:12:41 +0000270defm add_symbol
271 : Eq<"add-symbol", "Add new symbol <name> to .symtab. Accepted flags: "
272 "global, local, weak, default, hidden, file, section, object, "
273 "function, indirect-function. Accepted but ignored for "
274 "compatibility: debug, constructor, warning, indirect, synthetic, "
275 "unique-object, before.">,
276 MetaVarName<"name=[section:]value[,flags]">;