blob: 8ed6df9a9f6f7a415da20922a25976279ee6849d [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> {
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +00004 def NAME: Separate<["--", "-"], name>;
Fangrui Songab205a32018-11-01 17:20:40 +00005 def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>,
6 HelpText<help>;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +00007}
8
9def help : Flag<["-", "--"], "help">;
Fangrui Songab205a32018-11-01 17:20:40 +000010defm binary_architecture
11 : Eq<"binary-architecture", "Used when transforming an architecture-less "
12 "format (such as binary) to another format">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000013def B : JoinedOrSeparate<["-"], "B">,
14 Alias<binary_architecture>;
Fangrui Songab205a32018-11-01 17:20:40 +000015defm target : Eq<"target", "Format of the input and output file">,
Jordan Rupprechtbb4588e2018-10-12 00:36:01 +000016 Values<"binary">;
17def F : JoinedOrSeparate<[ "-" ], "F">, Alias<target>;
Fangrui Songab205a32018-11-01 17:20:40 +000018defm input_target : Eq<"input-target", "Format of the input file">,
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000019 Values<"binary">;
Jordan Rupprecht175ef5f2018-08-01 20:59:39 +000020def I : JoinedOrSeparate<[ "-" ], "I">, Alias<input_target>;
Fangrui Songab205a32018-11-01 17:20:40 +000021defm output_target : Eq<"output-target", "Format of the output file">,
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000022 Values<"binary">;
Puyan Lotfi99124cc2018-09-07 08:10:22 +000023def compress_debug_sections : Flag<["--", "-"], "compress-debug-sections">;
24def compress_debug_sections_eq : Joined<["--", "-"], "compress-debug-sections=">,
25 MetaVarName<"[ zlib | zlib-gnu ]">,
26 HelpText<"Compress DWARF debug sections using "
27 "specified style. Supported styles: "
28 "'zlib-gnu' and 'zlib'">;
Puyan Lotfiaf048642018-10-01 10:29:41 +000029def decompress_debug_sections : Flag<["-", "--"], "decompress-debug-sections">,
30 HelpText<"Decompress DWARF debug sections.">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000031def O : JoinedOrSeparate<["-"], "O">,
32 Alias<output_target>;
Fangrui Songab205a32018-11-01 17:20:40 +000033defm split_dwo
34 : Eq<"split-dwo", "Equivalent to extract-dwo on the input file to "
35 "<dwo-file>, then strip-dwo on the input file">,
36 MetaVarName<"dwo-file">;
Jordan Rupprechtd1767dc2018-08-16 18:29:40 +000037
38def preserve_dates : Flag<[ "-", "--" ], "preserve-dates">,
39 HelpText<"Preserve access and modification timestamps">;
40
41def p : Flag<[ "-" ], "p">, Alias<preserve_dates>;
42
Fangrui Songab205a32018-11-01 17:20:40 +000043defm add_gnu_debuglink : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">,
44 MetaVarName<"debug-file">;
45defm remove_section : Eq<"remove-section", "Remove <section>">,
46 MetaVarName<"section">;
Jordan Rupprechtd67c1e12018-08-01 16:23:22 +000047defm rename_section
Fangrui Songab205a32018-11-01 17:20:40 +000048 : Eq<"rename-section",
49 "Renames a section from old to new, optionally with specified flags. "
50 "Flags supported for GNU compatibility: alloc, load, noload, "
51 "readonly, debug, code, data, rom, share, contents, merge, strings.">,
52 MetaVarName<"old=new[,flag1,...]">;
53defm redefine_symbol : Eq<"redefine-sym", "Change the name of a symbol old to new">,
54 MetaVarName<"old=new">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000055def R : JoinedOrSeparate<["-"], "R">,
56 Alias<remove_section>;
Fangrui Songab205a32018-11-01 17:20:40 +000057defm keep : Eq<"keep", "Keep <section>">,
58 MetaVarName<"section">;
59defm only_keep : Eq<"only-keep", "Remove all but <section>">,
60 MetaVarName<"section">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000061def j : JoinedOrSeparate<["-"], "j">,
62 Alias<only_keep>;
Fangrui Songab205a32018-11-01 17:20:40 +000063defm add_section
64 : Eq<"add-section",
65 "Make a section named <section> with the contents of <file>.">,
66 MetaVarName<"section=file">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000067def strip_all : Flag<["-", "--"], "strip-all">,
Alexander Shaposhnikovb3bfd3b2018-04-24 21:44:13 +000068 HelpText<"Remove non-allocated sections other than .gnu.warning* sections">;
Jake Ehrlich5e498462018-10-09 21:14:09 +000069def S : Flag<["-"], "S">,
70 Alias<strip_all>;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000071def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">,
72 HelpText<"Compaitable with GNU objcopy's --strip-all">;
73def strip_debug : Flag<["-", "--"], "strip-debug">,
Alexander Shaposhnikovb3bfd3b2018-04-24 21:44:13 +000074 HelpText<"Remove all debug information">;
Alexander Shaposhnikovd6884792018-04-24 05:43:32 +000075def strip_dwo : Flag<["-", "--"], "strip-dwo">,
76 HelpText<"Remove all DWARF .dwo sections from file">;
77def strip_sections : Flag<["-", "--"], "strip-sections">,
78 HelpText<"Remove all section headers">;
79def strip_non_alloc : Flag<["-", "--"], "strip-non-alloc">,
80 HelpText<"Remove all non-allocated sections">;
81def extract_dwo : Flag<["-", "--"], "extract-dwo">,
82 HelpText<"Remove all sections that are not DWARF .dwo sections from file">;
83def localize_hidden : Flag<["-", "--"], "localize-hidden">,
84 HelpText<"Mark all symbols that have hidden or internal visibility as local">;
Fangrui Songab205a32018-11-01 17:20:40 +000085defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">,
86 MetaVarName<"symbol">;
Paul Semelb4924942018-04-26 17:44:43 +000087def L : JoinedOrSeparate<["-"], "L">,
88 Alias<localize_symbol>;
Fangrui Songab205a32018-11-01 17:20:40 +000089defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">,
90 MetaVarName<"symbol">;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +000091
92defm keep_global_symbol
Fangrui Songab205a32018-11-01 17:20:40 +000093 : Eq<"keep-global-symbol", "Convert all symbols except <symbol> to local. May be repeated "
94 "to convert all except a set of symbols to local.">,
95 MetaVarName<"symbol">;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +000096def G : JoinedOrSeparate<[ "-" ], "G">, Alias<keep_global_symbol>;
97
98defm keep_global_symbols
Fangrui Songab205a32018-11-01 17:20:40 +000099 : Eq<"keep-global-symbols",
100 "Reads a list of symbols from <filename> and runs as if "
101 "--keep-global-symbol=<symbol> is set for each one. <filename> "
102 "contains one symbol per line and may contain comments beginning "
103 "with '#'. Leading and trailing whitespace is stripped from each "
104 "line. May be repeated to read symbols from many files.">,
105 MetaVarName<"filename">;
Jordan Rupprechtbe8ebcc2018-08-17 22:34:48 +0000106
Jordan Rupprecht7b1c8162018-09-21 00:47:31 +0000107def version : Flag<[ "-", "--" ], "version">,
108 HelpText<"Print the version and exit.">;
109
Fangrui Songab205a32018-11-01 17:20:40 +0000110defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">,
111 MetaVarName<"symbol">;
Paul Semel3a8a56b2018-04-27 19:16:27 +0000112def W : JoinedOrSeparate<["-"], "W">,
113 Alias<weaken_symbol>;
Paul Semel2c0510f2018-05-02 20:14:49 +0000114def weaken : Flag<["-", "--"], "weaken">,
115 HelpText<"Mark all global symbols as weak">;
Paul Semel41695f82018-05-02 20:19:22 +0000116def discard_all : Flag<["-", "--"], "discard-all">,
117 HelpText<"Remove all local symbols except file and section symbols">;
118def x : Flag<["-"], "x">,
119 Alias<discard_all>;
Fangrui Songab205a32018-11-01 17:20:40 +0000120defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">,
121 MetaVarName<"symbol">;
Paul Semel4246a462018-05-09 21:36:54 +0000122def N : JoinedOrSeparate<["-"], "N">,
123 Alias<strip_symbol>;
Fangrui Songab205a32018-11-01 17:20:40 +0000124defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
125 MetaVarName<"symbol">;
Paul Semel5d97c822018-05-15 14:09:37 +0000126def K : JoinedOrSeparate<["-"], "K">,
127 Alias<keep_symbol>;
Jake Ehrliche40398a2018-05-15 20:53:53 +0000128def only_keep_debug : Flag<["-", "--"], "only-keep-debug">,
129 HelpText<"Currently ignored. Only for compaitability with GNU objcopy.">;
Paul Semel99dda0b2018-05-25 11:01:25 +0000130def strip_unneeded : Flag<["-", "--"], "strip-unneeded">,
131 HelpText<"Remove all symbols not needed by relocations">;
Paul Semelcf51c802018-05-26 08:10:37 +0000132def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">,
133 HelpText<"Do not remove file symbols">;
Fangrui Songab205a32018-11-01 17:20:40 +0000134defm dump_section : Eq<"dump-section", "Dump contents of section named <section> into file <file>">,
135 MetaVarName<"section=file">;
136defm prefix_symbols : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">,
137 MetaVarName<"prefix">;