]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/tools/llvm-objcopy/ObjcopyOpts.td
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / tools / llvm-objcopy / ObjcopyOpts.td
1 include "llvm/Option/OptParser.td"
2
3 multiclass 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
10 def help : Flag<["--"], "help">;
11 def h : Flag<["-"], "h">, Alias<help>;
12
13 def allow_broken_links
14     : Flag<["--"], "allow-broken-links">,
15       HelpText<"Allow llvm-objcopy to remove sections even if it would leave "
16                "invalid section references. The appropriate sh_link fields "
17                "will be set to zero.">;
18
19 defm binary_architecture
20     : Eq<"binary-architecture", "Used when transforming an architecture-less "
21                                 "format (such as binary) to another format">;
22 def B : JoinedOrSeparate<["-"], "B">, Alias<binary_architecture>;
23
24 defm target : Eq<"target", "Format of the input and output file">,
25               Values<"binary">;
26 def F : JoinedOrSeparate<["-"], "F">, Alias<target>;
27
28 defm input_target : Eq<"input-target", "Format of the input file">,
29                     Values<"binary">;
30 def I : JoinedOrSeparate<["-"], "I">, Alias<input_target>;
31
32 defm output_target : Eq<"output-target", "Format of the output file">,
33                      Values<"binary">;
34 def O : JoinedOrSeparate<["-"], "O">, Alias<output_target>;
35
36 def compress_debug_sections : Flag<["--"], "compress-debug-sections">;
37 def compress_debug_sections_eq
38     : Joined<["--"], "compress-debug-sections=">,
39       MetaVarName<"[ zlib | zlib-gnu ]">,
40       HelpText<"Compress DWARF debug sections using specified style. Supported "
41                "styles: 'zlib-gnu' and 'zlib'">;
42 def decompress_debug_sections : Flag<["--"], "decompress-debug-sections">,
43                                 HelpText<"Decompress DWARF debug sections.">;
44 defm split_dwo
45     : Eq<"split-dwo", "Equivalent to extract-dwo on the input file to "
46                       "<dwo-file>, then strip-dwo on the input file">,
47       MetaVarName<"dwo-file">;
48
49 def enable_deterministic_archives
50     : Flag<["--"], "enable-deterministic-archives">,
51       HelpText<"Enable deterministic mode when copying archives (use zero for "
52                "UIDs, GIDs, and timestamps).">;
53 def D : Flag<["-"], "D">,
54         Alias<enable_deterministic_archives>,
55         HelpText<"Alias for --enable-deterministic-archives">;
56
57 def disable_deterministic_archives
58     : Flag<["--"], "disable-deterministic-archives">,
59       HelpText<"Disable deterministic mode when copying archives (use real "
60                "values for UIDs, GIDs, and timestamps).">;
61 def U : Flag<["-"], "U">,
62         Alias<disable_deterministic_archives>,
63         HelpText<"Alias for --disable-deterministic-archives">;
64
65 def preserve_dates : Flag<["--"], "preserve-dates">,
66                      HelpText<"Preserve access and modification timestamps">;
67 def p : Flag<["-"], "p">, Alias<preserve_dates>;
68
69 defm add_gnu_debuglink
70     : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">,
71       MetaVarName<"debug-file">;
72
73 defm remove_section : Eq<"remove-section", "Remove <section>">,
74                       MetaVarName<"section">;
75 def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>;
76
77 defm rename_section
78     : Eq<"rename-section",
79          "Renames a section from old to new, optionally with specified flags. "
80          "Flags supported for GNU compatibility: alloc, load, noload, "
81          "readonly, debug, code, data, rom, share, contents, merge, strings.">,
82       MetaVarName<"old=new[,flag1,...]">;
83 defm redefine_symbol
84     : Eq<"redefine-sym", "Change the name of a symbol old to new">,
85       MetaVarName<"old=new">;
86 defm redefine_symbols
87     : Eq<"redefine-syms",
88          "Reads a list of symbol pairs from <filename> and runs as if "
89          "--redefine-sym=<old>=<new> is set for each one. <filename> "
90          "contains two symbols per line separated with whitespace and may "
91          "contain comments beginning with '#'. Leading and trailing "
92          "whitespace is stripped from each line. May be repeated to read "
93          "symbols from many files.">,         
94       MetaVarName<"filename">;
95
96 defm keep_section : Eq<"keep-section", "Keep <section>">,
97                     MetaVarName<"section">;
98 defm only_section : Eq<"only-section", "Remove all but <section>">,
99                     MetaVarName<"section">;
100 def j : JoinedOrSeparate<["-"], "j">, Alias<only_section>;
101 defm add_section
102     : Eq<"add-section",
103          "Make a section named <section> with the contents of <file>.">,
104       MetaVarName<"section=file">;
105
106 defm set_section_flags
107     : Eq<"set-section-flags",
108          "Set section flags for a given section. Flags supported for GNU "
109          "compatibility: alloc, load, noload, readonly, debug, code, data, "
110          "rom, share, contents, merge, strings.">,
111       MetaVarName<"section=flag1[,flag2,...]">;
112
113 def strip_all : Flag<["--"], "strip-all">,
114                 HelpText<"Remove non-allocated sections outside segments. "
115                          ".gnu.warning* sections are not removed">;
116 def S : Flag<["-"], "S">, Alias<strip_all>;
117 def strip_all_gnu : Flag<["--"], "strip-all-gnu">,
118                     HelpText<"Compatible with GNU objcopy's --strip-all">;
119 def strip_debug : Flag<["--"], "strip-debug">,
120                   HelpText<"Remove all debug information">;
121 def g : Flag<["-"], "g">, Alias<strip_debug>,
122         HelpText<"Alias for --strip-debug">;
123 def strip_dwo : Flag<["--"], "strip-dwo">,
124                 HelpText<"Remove all DWARF .dwo sections from file">;
125 def strip_sections
126     : Flag<["--"], "strip-sections">,
127       HelpText<"Remove all section headers and all sections not in segments">;
128 def strip_non_alloc
129     : Flag<["--"], "strip-non-alloc">,
130       HelpText<"Remove all non-allocated sections outside segments">;
131 def strip_unneeded : Flag<["--"], "strip-unneeded">,
132                      HelpText<"Remove all symbols not needed by relocations">;
133 defm strip_unneeded_symbol
134     : Eq<"strip-unneeded-symbol",
135          "Remove symbol <symbol> if it is not needed by relocations">,
136       MetaVarName<"symbol">;
137 defm strip_unneeded_symbols
138     : Eq<"strip-unneeded-symbols",
139          "Reads a list of symbols from <filename> and removes them "
140          "if they are not needed by relocations">,
141       MetaVarName<"filename">;
142
143 def extract_dwo
144     : Flag<["--"], "extract-dwo">,
145       HelpText<
146           "Remove all sections that are not DWARF .dwo sections from file">;
147
148 defm extract_partition
149     : Eq<"extract-partition", "Extract named partition from input file">,
150       MetaVarName<"name">;
151 def extract_main_partition
152     : Flag<["--"], "extract-main-partition">,
153       HelpText<"Extract main partition from the input file">;
154
155 def localize_hidden
156     : Flag<["--"], "localize-hidden">,
157       HelpText<
158           "Mark all symbols that have hidden or internal visibility as local">;
159 defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">,
160                        MetaVarName<"symbol">;
161 defm localize_symbols
162     : Eq<"localize-symbols",
163          "Reads a list of symbols from <filename> and marks them local.">,
164       MetaVarName<"filename">;
165
166 def L : JoinedOrSeparate<["-"], "L">, Alias<localize_symbol>;
167
168 defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
169                         MetaVarName<"symbol">;
170
171 defm globalize_symbols
172     : Eq<"globalize-symbols",
173          "Reads a list of symbols from <filename> and marks them global.">,
174       MetaVarName<"filename">;
175
176 defm keep_global_symbol
177     : Eq<"keep-global-symbol",
178          "Convert all symbols except <symbol> to local. May be repeated to "
179          "convert all except a set of symbols to local.">,
180       MetaVarName<"symbol">;
181 def G : JoinedOrSeparate<["-"], "G">, Alias<keep_global_symbol>;
182
183 defm keep_global_symbols
184     : Eq<"keep-global-symbols",
185          "Reads a list of symbols from <filename> and runs as if "
186          "--keep-global-symbol=<symbol> is set for each one. <filename> "
187          "contains one symbol per line and may contain comments beginning with "
188          "'#'. Leading and trailing whitespace is stripped from each line. May "
189          "be repeated to read symbols from many files.">,
190       MetaVarName<"filename">;
191
192 defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">,
193                      MetaVarName<"symbol">;
194 defm weaken_symbols
195     : Eq<"weaken-symbols",
196          "Reads a list of symbols from <filename> and marks them weak.">,
197       MetaVarName<"filename">;
198
199 def W : JoinedOrSeparate<["-"], "W">, Alias<weaken_symbol>;
200 def weaken : Flag<["--"], "weaken">,
201              HelpText<"Mark all global symbols as weak">;
202
203 def discard_locals : Flag<["--"], "discard-locals">,
204                      HelpText<"Remove compiler-generated local symbols, (e.g. "
205                               "symbols starting with .L)">;
206 def X : Flag<["-"], "X">, Alias<discard_locals>;
207
208 def discard_all
209     : Flag<["--"], "discard-all">,
210       HelpText<"Remove all local symbols except file and section symbols">;
211 def x : Flag<["-"], "x">, Alias<discard_all>;
212 defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">,
213                     MetaVarName<"symbol">;
214 defm strip_symbols
215     : Eq<"strip-symbols",
216          "Reads a list of symbols from <filename> and removes them.">,
217       MetaVarName<"filename">;
218
219 def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>;
220 defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
221                    MetaVarName<"symbol">;
222 def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
223
224 defm keep_symbols
225     : Eq<"keep-symbols",
226          "Reads a list of symbols from <filename> and runs as if "
227          "--keep-symbol=<symbol> is set for each one. <filename> "
228          "contains one symbol per line and may contain comments beginning with "
229          "'#'. Leading and trailing whitespace is stripped from each line. May "
230          "be repeated to read symbols from many files.">,
231       MetaVarName<"filename">;
232
233 def only_keep_debug
234     : Flag<["--"], "only-keep-debug">,
235       HelpText<"Clear sections that would not be stripped by --strip-debug. "
236                "Currently only implemented for COFF.">;
237
238 def keep_file_symbols : Flag<["--"], "keep-file-symbols">,
239                         HelpText<"Do not remove file symbols">;
240 defm dump_section
241     : Eq<"dump-section",
242          "Dump contents of section named <section> into file <file>">,
243       MetaVarName<"section=file">;
244 defm prefix_symbols
245     : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">,
246       MetaVarName<"prefix">;
247
248 defm prefix_alloc_sections
249     : Eq<"prefix-alloc-sections", "Add <prefix> to the start of every allocated section name">,
250       MetaVarName<"prefix">;
251
252 def version : Flag<["--"], "version">,
253               HelpText<"Print the version and exit.">;
254 def V : Flag<["-"], "V">, Alias<version>;
255 defm build_id_link_dir
256     : Eq<"build-id-link-dir", "Set directory for --build-id-link-input and "
257                               "--build-id-link-output to <dir>">,
258       MetaVarName<"dir">;
259 defm build_id_link_input
260     : Eq<"build-id-link-input", "Hard-link the input to <dir>/xx/xxx<suffix> "
261                                 "name derived from hex build ID">,
262       MetaVarName<"suffix">;
263 defm build_id_link_output
264     : Eq<"build-id-link-output", "Hard-link the output to <dir>/xx/xxx<suffix> "
265                                  "name derived from hex build ID">,
266       MetaVarName<"suffix">;
267
268 def regex
269     : Flag<["--"], "regex">,
270       HelpText<"Permit regular expressions in name comparison">;
271
272 defm set_start : Eq<"set-start", "Set the start address to <addr>. Overrides "
273                     "any previous --change-start or --adjust-start values.">,
274                  MetaVarName<"addr">;
275 defm change_start : Eq<"change-start", "Add <incr> to the start address. Can be "                        
276                        "specified multiple times, all values will be applied "
277                        "cumulatively.">,
278                     MetaVarName<"incr">;
279 def adjust_start : JoinedOrSeparate<["--"], "adjust-start">,
280                    Alias<change_start>;
281
282 defm add_symbol
283     : Eq<"add-symbol", "Add new symbol <name> to .symtab. Accepted flags: "
284          "global, local, weak, default, hidden, file, section, object, "
285          "function, indirect-function. Accepted but ignored for "
286          "compatibility: debug, constructor, warning, indirect, synthetic, "
287          "unique-object, before.">,
288       MetaVarName<"name=[section:]value[,flags]">;