xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-objcopy/ObjcopyOpts.td (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1include "CommonOpts.td"
2
3multiclass B<string name, string help1, string help2> {
4  def NAME: Flag<["--"], name>, HelpText<help1>;
5  def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
6}
7
8defm binary_architecture
9    : Eq<"binary-architecture", "Ignored for compatibility">;
10def B : JoinedOrSeparate<["-"], "B">,
11        Alias<binary_architecture>,
12        HelpText<"Alias for --binary-architecture">;
13
14defm target : Eq<"target", "Equivalent to --input-target and --output-target for the specified format">,
15              Values<"binary">;
16def F : JoinedOrSeparate<["-"], "F">,
17        Alias<target>,
18        HelpText<"Alias for --target">;
19
20defm input_target : Eq<"input-target", "Read the input as the specified format">, MetaVarName<"format">;
21def I : JoinedOrSeparate<["-"], "I">,
22        Alias<input_target>,
23        HelpText<"Alias for --input-target">;
24
25defm output_target : Eq<"output-target", "Write the output as the specified format">, MetaVarName<"format">;
26def O : JoinedOrSeparate<["-"], "O">,
27        Alias<output_target>,
28        HelpText<"Alias for --output-target">;
29
30defm new_symbol_visibility
31    : Eq<"new-symbol-visibility", "Specify the visibility of symbols automatically "
32         "created when using binary input or --add-symbol. The default is 'default'">;
33
34def compress_debug_sections
35    : Joined<["--"], "compress-debug-sections=">,
36      MetaVarName<"format">,
37      HelpText<"Compress DWARF debug sections using specified format. Supported "
38               "formats: zlib, zstd. Select zlib if <format> is omitted">;
39def : Flag<["--"], "compress-debug-sections">, Alias<compress_debug_sections>,
40      AliasArgs<["zlib"]>;
41def decompress_debug_sections : Flag<["--"], "decompress-debug-sections">,
42                                HelpText<"Decompress DWARF debug sections">;
43defm compress_sections
44    : Eq<"compress-sections",
45         "Compress or decompress sections using specified format. Supported "
46         "formats: zlib, zstd. Specify 'none' for decompression">,
47      MetaVarName<"<section-glob>=<format>">;
48
49defm split_dwo
50    : Eq<"split-dwo", "Equivalent to --extract-dwo and <dwo-file> as the output file and no other options, "
51                      "and then --strip-dwo on the input file">,
52      MetaVarName<"dwo-file">;
53
54defm add_gnu_debuglink
55    : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">,
56      MetaVarName<"debug-file">;
57
58defm rename_section
59    : Eq<"rename-section",
60         "Rename sections called <old> to <new>, and apply any specified <flag> values. "
61         "See --set-section-flags for a list of supported flags">,
62      MetaVarName<"old=new[,flag1,...]">;
63defm redefine_symbol
64    : Eq<"redefine-sym", "Change the name of a symbol old to new">,
65      MetaVarName<"old=new">;
66defm redefine_symbols
67    : Eq<"redefine-syms",
68         "Read a list of symbol pairs from <filename> and run as if "
69         "--redefine-sym=<old>=<new> is set for each one. <filename> "
70         "contains two symbols per line separated with whitespace and may "
71         "contain comments beginning with '#'. Leading and trailing "
72         "whitespace is stripped from each line. May be repeated to read "
73         "symbols from many files">,
74      MetaVarName<"filename">;
75
76defm only_section : Eq<"only-section", "Remove all but <section>">,
77                    MetaVarName<"section">;
78def j : JoinedOrSeparate<["-"], "j">,
79        Alias<only_section>,
80        HelpText<"Alias for --only-section">;
81defm add_section
82    : Eq<"add-section",
83         "Add a section named <section> with the contents of <file>">,
84      MetaVarName<"section=file">;
85
86defm set_section_alignment
87    : Eq<"set-section-alignment", "Set alignment for a given section">,
88      MetaVarName<"section=align">;
89
90defm set_section_flags
91    : Eq<"set-section-flags",
92         "Set section properties based on the specified <flags>. Supported flag names are: "
93         "alloc, load, noload, readonly, exclude, debug, code, "
94         "data, rom, share, contents, merge, strings, large">,
95      MetaVarName<"section=flag1[,flag2,...]">;
96
97defm set_section_type
98    : Eq<"set-section-type",
99         "Set the type of section <section> to the integer <type>">,
100      MetaVarName<"section=type">;
101
102defm set_symbol_visibility
103    : Eq<"set-symbol-visibility",
104         "Change the visibility of a symbol to the specified value">,
105      MetaVarName<"symbol=visibility">;
106defm set_symbols_visibility
107    : Eq<"set-symbols-visibility",
108         "Read a list of symbols from <filename> and change their "
109         "visibility to the specified value. Visibility values: default, "
110         "internal, hidden, protected">,
111      MetaVarName<"filename=visibility">;
112
113def S : Flag<["-"], "S">,
114        Alias<strip_all>,
115        HelpText<"Alias for --strip-all">;
116def strip_dwo : Flag<["--"], "strip-dwo">,
117                HelpText<"Remove all DWARF .dwo sections">;
118def strip_non_alloc
119    : Flag<["--"], "strip-non-alloc">,
120      HelpText<"Remove all non-allocated sections that are not within segments">;
121defm strip_unneeded_symbol
122    : Eq<"strip-unneeded-symbol",
123         "Remove all symbols named <symbol> that are local or undefined and "
124         "are not required by any relocation">,
125      MetaVarName<"symbol">;
126defm strip_unneeded_symbols
127    : Eq<"strip-unneeded-symbols",
128         "Remove all symbols whose names appear in the file <file>, if they "
129         "are local or undefined and are not required by any relocation">,
130      MetaVarName<"filename">;
131
132defm subsystem
133    : Eq<"subsystem",
134         "Set the PE subsystem, and optionally subsystem version">,
135      MetaVarName<"name[:version]">, Group<grp_coff>;
136
137def extract_dwo
138    : Flag<["--"], "extract-dwo">,
139      HelpText<
140          "Remove all sections that are not DWARF .dwo sections from file">;
141
142defm extract_partition
143    : Eq<"extract-partition", "Extract named partition from input file">,
144      MetaVarName<"name">;
145def extract_main_partition
146    : Flag<["--"], "extract-main-partition">,
147      HelpText<"Extract main partition from the input file">;
148
149def localize_hidden
150    : Flag<["--"], "localize-hidden">,
151      HelpText<
152          "Mark all symbols that have hidden or internal visibility as local">;
153defm localize_symbol
154    : Eq<"localize-symbol", "Mark any defined non-common symbol named <symbol> as local">,
155      MetaVarName<"symbol">;
156defm localize_symbols
157    : Eq<"localize-symbols",
158         "Read a list of names from <filename> and mark any defined non-common "
159         "symbols with those names as local">,
160      MetaVarName<"filename">;
161
162def L : JoinedOrSeparate<["-"], "L">,
163        Alias<localize_symbol>,
164        HelpText<"Alias for --localize-symbol">;
165
166defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
167                        MetaVarName<"symbol">;
168
169defm globalize_symbols
170    : Eq<"globalize-symbols",
171         "Read a list of symbols from <filename> and mark defined symbols"
172         " with those names as global">,
173      MetaVarName<"filename">;
174
175defm keep_global_symbol
176    : Eq<"keep-global-symbol",
177         "Mark all symbols local, except for symbols with the name <symbol>. "
178         "Can be specified multiple times to ignore multiple symbols">,
179      MetaVarName<"symbol">;
180def G : JoinedOrSeparate<["-"], "G">,
181        Alias<keep_global_symbol>,
182        HelpText<"Alias for --keep-global-symbol">;
183
184defm verify_note_sections : B<"verify-note-sections",
185                              "Validate note sections",
186                              "Don't validate note sections">;
187
188defm keep_global_symbols
189    : Eq<"keep-global-symbols",
190         "Read a list of symbols from <filename> and run as if "
191         "--keep-global-symbol=<symbol> is set for each one. <filename> "
192         "contains one symbol per line and may contain comments beginning with "
193         "'#'. Leading and trailing whitespace is stripped from each line. May "
194         "be repeated to read symbols from many files">,
195      MetaVarName<"filename">;
196
197defm weaken_symbol : Eq<"weaken-symbol", "Mark global symbols named <symbol> as weak">,
198                     MetaVarName<"symbol">;
199defm weaken_symbols
200    : Eq<"weaken-symbols",
201         "Read a list of symbols from <filename> and mark global symbols with those names as weak">,
202      MetaVarName<"filename">;
203
204def W : JoinedOrSeparate<["-"], "W">,
205        Alias<weaken_symbol>,
206        HelpText<"Alias for --weaken-symbol">;
207def weaken : Flag<["--"], "weaken">,
208             HelpText<"Mark all defined global symbols as weak">;
209
210defm strip_symbols
211    : Eq<"strip-symbols",
212         "Remove all symbols whose names appear in the file <filename>">,
213      MetaVarName<"filename">;
214
215defm keep_symbols
216    : Eq<"keep-symbols",
217         "Read a list of symbols from <filename> and run as if "
218         "--keep-symbol=<symbol> is set for each one. <filename> "
219         "contains one symbol per line and may contain comments beginning with "
220         "'#'. Leading and trailing whitespace is stripped from each line. May "
221         "be repeated to read symbols from many files">,
222      MetaVarName<"filename">;
223
224defm skip_symbol : Eq<"skip-symbol", "Do not change parameters of symbol <symbol> "
225                        "when executing other options that can change the symbol's "
226                        "name, binding or visibility">,
227                     MetaVarName<"symbol">;
228
229defm skip_symbols
230    : Eq<"skip-symbols",
231         "Read a list of symbols from <filename> and run as if "
232         "--skip-symbol=<symbol> is set for each one. <filename> "
233         "contains one symbol per line and may contain comments beginning with "
234         "'#'. Leading and trailing whitespace is stripped from each line. May "
235         "be repeated to read symbols from many files">,
236      MetaVarName<"filename">;
237
238defm dump_section
239    : Eq<"dump-section",
240         "Dump contents of section named <section> into file <file>">,
241      MetaVarName<"section=file">;
242defm prefix_symbols
243    : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">,
244      MetaVarName<"prefix">;
245defm remove_symbol_prefix
246    : Eq<"remove-symbol-prefix",
247         "Remove <prefix> from the start of every symbol name. No-op for symbols that do not start "
248         "with <prefix>">,
249      MetaVarName<"prefix">;
250
251defm prefix_alloc_sections
252    : Eq<"prefix-alloc-sections", "Add <prefix> to the start of every allocated section name">,
253      MetaVarName<"prefix">;
254
255defm set_start : Eq<"set-start", "Set the start address to <addr>. Overrides "
256                    "any previous --change-start or --adjust-start values">,
257                 MetaVarName<"addr">;
258defm change_start : Eq<"change-start", "Add <incr> to the start address. Can be "
259                       "specified multiple times, all values will be applied "
260                       "cumulatively">,
261                    MetaVarName<"incr">;
262def adjust_start : JoinedOrSeparate<["--"], "adjust-start">,
263                   Alias<change_start>,
264                   HelpText<"Alias for --change-start">;
265
266defm change_section_lma
267    : Eq<"change-section-lma", "Shift LMA of non-zero-sized sections in the program header by <val>">,
268      MetaVarName<"*{+|-}val">;
269
270defm add_symbol
271    : Eq<"add-symbol", "Add new symbol <name> to .symtab. Accepted flags: "
272         "global, local, weak, default, hidden, protected, 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]">;
277
278defm update_section
279    : Eq<"update-section", "Replace the contents of section <name> with contents from a file <file>">,
280      MetaVarName<"name=file">;
281
282defm gap_fill
283    : Eq<"gap-fill", "Fill the gaps between sections with <value> instead of zero. "
284                     "<value> must be an unsigned 8-bit integer. "
285                     "This option is only supported for ELF input and binary output">,
286      MetaVarName<"value">;
287
288defm pad_to
289    : Eq<"pad-to", "Pad the output up to the load address <address>, using a value "
290                   "of zero or the value specified by the --gap-fill option. "
291                   "This option is only supported for ELF input and binary output">,
292      MetaVarName<"address">;
293