blob: 1f7e64e4091c811f23a3fce36148288d624adef6 [file] [log] [blame]
Alexander Shaposhnikovae1ca022018-04-24 05:43:32 +00001include "llvm/Option/OptParser.td"
2
Fangrui Songd919ed92018-11-01 17:20:40 +00003multiclass Eq<string name, string help> {
Jordan Rupprecht78ba7a62018-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 Shaposhnikovae1ca022018-04-24 05:43:32 +00008}
9
10def help : Flag<["-", "--"], "help">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000011
Fangrui Songd919ed92018-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 Rupprecht78ba7a62018-11-01 21:38:14 +000015def B : JoinedOrSeparate<["-"], "B">, Alias<binary_architecture>;
16
Fangrui Songd919ed92018-11-01 17:20:40 +000017defm target : Eq<"target", "Format of the input and output file">,
Jordan Rupprecht3b7de9d2018-10-12 00:36:01 +000018 Values<"binary">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000019def F : JoinedOrSeparate<["-"], "F">, Alias<target>;
20
Fangrui Songd919ed92018-11-01 17:20:40 +000021defm input_target : Eq<"input-target", "Format of the input file">,
Alexander Shaposhnikovae1ca022018-04-24 05:43:32 +000022 Values<"binary">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000023def I : JoinedOrSeparate<["-"], "I">, Alias<input_target>;
24
Fangrui Songd919ed92018-11-01 17:20:40 +000025defm output_target : Eq<"output-target", "Format of the output file">,
Alexander Shaposhnikovae1ca022018-04-24 05:43:32 +000026 Values<"binary">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000027def O : JoinedOrSeparate<["-"], "O">, Alias<output_target>;
28
Puyan Lotfiac820be2018-09-07 08:10:22 +000029def compress_debug_sections : Flag<["--", "-"], "compress-debug-sections">;
Jordan Rupprecht78ba7a62018-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 Lotficc27a052018-10-01 10:29:41 +000035def decompress_debug_sections : Flag<["-", "--"], "decompress-debug-sections">,
36 HelpText<"Decompress DWARF debug sections.">;
Fangrui Songd919ed92018-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 Rupprecht7b455c42018-08-16 18:29:40 +000041
Jordan Rupprecht167fb182018-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 Rupprecht78ba7a62018-11-01 21:38:14 +000058def preserve_dates : Flag<["-", "--"], "preserve-dates">,
Jordan Rupprecht7b455c42018-08-16 18:29:40 +000059 HelpText<"Preserve access and modification timestamps">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000060def p : Flag<["-"], "p">, Alias<preserve_dates>;
Jordan Rupprecht7b455c42018-08-16 18:29:40 +000061
Jordan Rupprecht78ba7a62018-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 Rupprecht7b455c42018-08-16 18:29:40 +000065
Fangrui Songd919ed92018-11-01 17:20:40 +000066defm remove_section : Eq<"remove-section", "Remove <section>">,
67 MetaVarName<"section">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000068def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>;
69
Jordan Rupprecht742c6792018-08-01 16:23:22 +000070defm rename_section
Fangrui Songd919ed92018-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 Rupprecht78ba7a62018-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">;
Jordan Rupprecht65bac062018-11-13 19:32:27 +000079defm keep_section : Eq<"keep-section", "Keep <section>">,
80 MetaVarName<"section">;
Jake Ehrlichbeec7d492018-12-06 02:03:53 +000081defm only_section : Eq<"only-section", "Remove all but <section>">,
82 MetaVarName<"section">;
83def j : JoinedOrSeparate<["-"], "j">, Alias<only_section>;
Fangrui Songd919ed92018-11-01 17:20:40 +000084defm add_section
85 : Eq<"add-section",
86 "Make a section named <section> with the contents of <file>.">,
87 MetaVarName<"section=file">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +000088
89def strip_all
90 : Flag<["-", "--"], "strip-all">,
91 HelpText<
92 "Remove non-allocated sections other than .gnu.warning* sections">;
93def S : Flag<["-"], "S">, Alias<strip_all>;
Alexander Shaposhnikovae1ca022018-04-24 05:43:32 +000094def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
Jordan Rupprecht9a78ad02018-11-01 17:48:46 +000095 HelpText<"Compatible with GNU objcopy's --strip-all">;
Alexander Shaposhnikovae1ca022018-04-24 05:43:32 +000096def strip_debug : Flag<["-", "--"], "strip-debug">,
Alexander Shaposhnikov86e361f2018-04-24 21:44:13 +000097 HelpText<"Remove all debug information">;
Alexander Shaposhnikovae1ca022018-04-24 05:43:32 +000098def strip_dwo : Flag<["-", "--"], "strip-dwo">,
99 HelpText<"Remove all DWARF .dwo sections from file">;
100def strip_sections : Flag<["-", "--"], "strip-sections">,
101 HelpText<"Remove all section headers">;
102def strip_non_alloc : Flag<["-", "--"], "strip-non-alloc">,
103 HelpText<"Remove all non-allocated sections">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000104def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
105 HelpText<"Remove all symbols not needed by relocations">;
106
107def extract_dwo
108 : Flag<["-", "--"], "extract-dwo">,
109 HelpText<
110 "Remove all sections that are not DWARF .dwo sections from file">;
111
112def localize_hidden
113 : Flag<["-", "--"], "localize-hidden">,
114 HelpText<
115 "Mark all symbols that have hidden or internal visibility as local">;
Fangrui Songd919ed92018-11-01 17:20:40 +0000116defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">,
117 MetaVarName<"symbol">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000118def L : JoinedOrSeparate<["-"], "L">, Alias<localize_symbol>;
Jordan Rupprechtdc7a8882018-08-17 22:34:48 +0000119
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000120defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
121 MetaVarName<"symbol">;
Jordan Rupprechtdc7a8882018-08-17 22:34:48 +0000122defm keep_global_symbol
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000123 : Eq<"keep-global-symbol",
124 "Convert all symbols except <symbol> to local. May be repeated to "
125 "convert all except a set of symbols to local.">,
Fangrui Songd919ed92018-11-01 17:20:40 +0000126 MetaVarName<"symbol">;
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000127def G : JoinedOrSeparate<["-"], "G">, Alias<keep_global_symbol>;
Jordan Rupprechtdc7a8882018-08-17 22:34:48 +0000128
129defm keep_global_symbols
Fangrui Songd919ed92018-11-01 17:20:40 +0000130 : Eq<"keep-global-symbols",
131 "Reads a list of symbols from <filename> and runs as if "
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000132 "--keep-global-symbol=<symbol> is set for each one. <filename> "
133 "contains one symbol per line and may contain comments beginning with "
134 "'#'. Leading and trailing whitespace is stripped from each line. May "
135 "be repeated to read symbols from many files.">,
Fangrui Songd919ed92018-11-01 17:20:40 +0000136 MetaVarName<"filename">;
Jordan Rupprechtdc7a8882018-08-17 22:34:48 +0000137
Fangrui Songd919ed92018-11-01 17:20:40 +0000138defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">,
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000139 MetaVarName<"symbol">;
140def W : JoinedOrSeparate<["-"], "W">, Alias<weaken_symbol>;
Paul Semelb4db0442018-05-02 20:14:49 +0000141def weaken : Flag<["-", "--"], "weaken">,
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000142 HelpText<"Mark all global symbols as weak">;
143def discard_all
144 : Flag<["-", "--"], "discard-all">,
145 HelpText<"Remove all local symbols except file and section symbols">;
146def x : Flag<["-"], "x">, Alias<discard_all>;
Fangrui Songd919ed92018-11-01 17:20:40 +0000147defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">,
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000148 MetaVarName<"symbol">;
149def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>;
Fangrui Songd919ed92018-11-01 17:20:40 +0000150defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000151 MetaVarName<"symbol">;
152def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
153def only_keep_debug
154 : Flag<["-", "--"], "only-keep-debug">,
155 HelpText<"Currently ignored. Only for compatibility with GNU objcopy.">;
Paul Semel5af80c62018-05-26 08:10:37 +0000156def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
Jordan Rupprecht78ba7a62018-11-01 21:38:14 +0000157 HelpText<"Do not remove file symbols">;
158defm dump_section
159 : Eq<"dump-section",
160 "Dump contents of section named <section> into file <file>">,
161 MetaVarName<"section=file">;
162defm prefix_symbols
163 : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">,
164 MetaVarName<"prefix">;
165
166def version : Flag<["-", "--"], "version">,
167 HelpText<"Print the version and exit.">;
Martin Storsjo3eeed742018-11-28 06:51:50 +0000168def V : Flag<["-"], "V">, Alias<version>;
Jake Ehrlich14107a32018-12-03 19:49:23 +0000169defm build_id_link_dir
170 : Eq<"build-id-link-dir", "Set directory for --build-id-link-input and "
171 "--build-id-link-output to <dir>">,
172 MetaVarName<"dir">;
173defm build_id_link_input
174 : Eq<"build-id-link-input", "Hard-link the input to <dir>/xx/xxx<suffix> "
175 "name derived from hex build ID">,
176 MetaVarName<"suffix">;
177defm build_id_link_output
178 : Eq<"build-id-link-output", "Hard-link the output to <dir>/xx/xxx<suffix> "
179 "name derived from hex build ID">,
180 MetaVarName<"suffix">;