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