Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 1 | include "llvm/Option/OptParser.td" |
| 2 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 3 | multiclass Eq<string name, string help> { |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 4 | def NAME : Separate<["--", "-"], name>; |
| 5 | def NAME #_eq : Joined<["--", "-"], name #"=">, |
| 6 | Alias<!cast<Separate>(NAME)>, |
| 7 | HelpText<help>; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | def help : Flag<["-", "--"], "help">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 11 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 12 | defm binary_architecture |
| 13 | : Eq<"binary-architecture", "Used when transforming an architecture-less " |
| 14 | "format (such as binary) to another format">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 15 | def B : JoinedOrSeparate<["-"], "B">, Alias<binary_architecture>; |
| 16 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 17 | defm target : Eq<"target", "Format of the input and output file">, |
Jordan Rupprecht | bb4588e | 2018-10-12 00:36:01 +0000 | [diff] [blame] | 18 | Values<"binary">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 19 | def F : JoinedOrSeparate<["-"], "F">, Alias<target>; |
| 20 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 21 | defm input_target : Eq<"input-target", "Format of the input file">, |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 22 | Values<"binary">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 23 | def I : JoinedOrSeparate<["-"], "I">, Alias<input_target>; |
| 24 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 25 | defm output_target : Eq<"output-target", "Format of the output file">, |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 26 | Values<"binary">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 27 | def O : JoinedOrSeparate<["-"], "O">, Alias<output_target>; |
| 28 | |
Puyan Lotfi | 99124cc | 2018-09-07 08:10:22 +0000 | [diff] [blame] | 29 | def compress_debug_sections : Flag<["--", "-"], "compress-debug-sections">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 30 | def 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 Lotfi | af04864 | 2018-10-01 10:29:41 +0000 | [diff] [blame] | 35 | def decompress_debug_sections : Flag<["-", "--"], "decompress-debug-sections">, |
| 36 | HelpText<"Decompress DWARF debug sections.">; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 37 | defm 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 Rupprecht | d1767dc | 2018-08-16 18:29:40 +0000 | [diff] [blame] | 41 | |
Jordan Rupprecht | fc780bb | 2018-11-01 17:36:37 +0000 | [diff] [blame] | 42 | def enable_deterministic_archives |
| 43 | : Flag<["-", "--"], "enable-deterministic-archives">, |
| 44 | HelpText<"Enable deterministic mode when copying archives (use zero for " |
| 45 | "UIDs, GIDs, and timestamps).">; |
| 46 | def D : Flag<["-"], "D">, |
| 47 | Alias<enable_deterministic_archives>, |
| 48 | HelpText<"Alias for --enable-deterministic-archives">; |
| 49 | |
| 50 | def 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).">; |
| 54 | def U : Flag<["-"], "U">, |
| 55 | Alias<disable_deterministic_archives>, |
| 56 | HelpText<"Alias for --disable-deterministic-archives">; |
| 57 | |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 58 | def preserve_dates : Flag<["-", "--"], "preserve-dates">, |
Jordan Rupprecht | d1767dc | 2018-08-16 18:29:40 +0000 | [diff] [blame] | 59 | HelpText<"Preserve access and modification timestamps">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 60 | def p : Flag<["-"], "p">, Alias<preserve_dates>; |
Jordan Rupprecht | d1767dc | 2018-08-16 18:29:40 +0000 | [diff] [blame] | 61 | |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 62 | defm add_gnu_debuglink |
| 63 | : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">, |
| 64 | MetaVarName<"debug-file">; |
Jordan Rupprecht | d1767dc | 2018-08-16 18:29:40 +0000 | [diff] [blame] | 65 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 66 | defm remove_section : Eq<"remove-section", "Remove <section>">, |
| 67 | MetaVarName<"section">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 68 | def R : JoinedOrSeparate<["-"], "R">, Alias<remove_section>; |
| 69 | |
Jordan Rupprecht | d67c1e1 | 2018-08-01 16:23:22 +0000 | [diff] [blame] | 70 | defm rename_section |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 71 | : 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 Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 76 | defm redefine_symbol |
| 77 | : Eq<"redefine-sym", "Change the name of a symbol old to new">, |
| 78 | MetaVarName<"old=new">; |
| 79 | defm keep : Eq<"keep", "Keep <section>">, MetaVarName<"section">; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 80 | defm only_keep : Eq<"only-keep", "Remove all but <section>">, |
| 81 | MetaVarName<"section">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 82 | def j : JoinedOrSeparate<["-"], "j">, Alias<only_keep>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 83 | defm add_section |
| 84 | : Eq<"add-section", |
| 85 | "Make a section named <section> with the contents of <file>.">, |
| 86 | MetaVarName<"section=file">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 87 | |
| 88 | def strip_all |
| 89 | : Flag<["-", "--"], "strip-all">, |
| 90 | HelpText< |
| 91 | "Remove non-allocated sections other than .gnu.warning* sections">; |
| 92 | def S : Flag<["-"], "S">, Alias<strip_all>; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 93 | def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">, |
Jordan Rupprecht | 30d1b19 | 2018-11-01 17:48:46 +0000 | [diff] [blame] | 94 | HelpText<"Compatible with GNU objcopy's --strip-all">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 95 | def strip_debug : Flag<["-", "--"], "strip-debug">, |
Alexander Shaposhnikov | b3bfd3b | 2018-04-24 21:44:13 +0000 | [diff] [blame] | 96 | HelpText<"Remove all debug information">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 97 | def strip_dwo : Flag<["-", "--"], "strip-dwo">, |
| 98 | HelpText<"Remove all DWARF .dwo sections from file">; |
| 99 | def strip_sections : Flag<["-", "--"], "strip-sections">, |
| 100 | HelpText<"Remove all section headers">; |
| 101 | def strip_non_alloc : Flag<["-", "--"], "strip-non-alloc">, |
| 102 | HelpText<"Remove all non-allocated sections">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 103 | def strip_unneeded : Flag<["-", "--"], "strip-unneeded">, |
| 104 | HelpText<"Remove all symbols not needed by relocations">; |
| 105 | |
| 106 | def extract_dwo |
| 107 | : Flag<["-", "--"], "extract-dwo">, |
| 108 | HelpText< |
| 109 | "Remove all sections that are not DWARF .dwo sections from file">; |
| 110 | |
| 111 | def localize_hidden |
| 112 | : Flag<["-", "--"], "localize-hidden">, |
| 113 | HelpText< |
| 114 | "Mark all symbols that have hidden or internal visibility as local">; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 115 | defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">, |
| 116 | MetaVarName<"symbol">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 117 | def L : JoinedOrSeparate<["-"], "L">, Alias<localize_symbol>; |
Jordan Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 118 | |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 119 | defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">, |
| 120 | MetaVarName<"symbol">; |
Jordan Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 121 | defm keep_global_symbol |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 122 | : Eq<"keep-global-symbol", |
| 123 | "Convert all symbols except <symbol> to local. May be repeated to " |
| 124 | "convert all except a set of symbols to local.">, |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 125 | MetaVarName<"symbol">; |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 126 | def G : JoinedOrSeparate<["-"], "G">, Alias<keep_global_symbol>; |
Jordan Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 127 | |
| 128 | defm keep_global_symbols |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 129 | : Eq<"keep-global-symbols", |
| 130 | "Reads a list of symbols from <filename> and runs as if " |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 131 | "--keep-global-symbol=<symbol> is set for each one. <filename> " |
| 132 | "contains one symbol per line and may contain comments beginning with " |
| 133 | "'#'. Leading and trailing whitespace is stripped from each line. May " |
| 134 | "be repeated to read symbols from many files.">, |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 135 | MetaVarName<"filename">; |
Jordan Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 136 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 137 | defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">, |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 138 | MetaVarName<"symbol">; |
| 139 | def W : JoinedOrSeparate<["-"], "W">, Alias<weaken_symbol>; |
Paul Semel | 2c0510f | 2018-05-02 20:14:49 +0000 | [diff] [blame] | 140 | def weaken : Flag<["-", "--"], "weaken">, |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 141 | HelpText<"Mark all global symbols as weak">; |
| 142 | def discard_all |
| 143 | : Flag<["-", "--"], "discard-all">, |
| 144 | HelpText<"Remove all local symbols except file and section symbols">; |
| 145 | def x : Flag<["-"], "x">, Alias<discard_all>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 146 | defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">, |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 147 | MetaVarName<"symbol">; |
| 148 | def N : JoinedOrSeparate<["-"], "N">, Alias<strip_symbol>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame] | 149 | defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">, |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 150 | MetaVarName<"symbol">; |
| 151 | def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>; |
| 152 | def only_keep_debug |
| 153 | : Flag<["-", "--"], "only-keep-debug">, |
| 154 | HelpText<"Currently ignored. Only for compatibility with GNU objcopy.">; |
Paul Semel | cf51c80 | 2018-05-26 08:10:37 +0000 | [diff] [blame] | 155 | def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">, |
Jordan Rupprecht | 56c0ee0 | 2018-11-01 21:38:14 +0000 | [diff] [blame^] | 156 | HelpText<"Do not remove file symbols">; |
| 157 | defm dump_section |
| 158 | : Eq<"dump-section", |
| 159 | "Dump contents of section named <section> into file <file>">, |
| 160 | MetaVarName<"section=file">; |
| 161 | defm prefix_symbols |
| 162 | : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">, |
| 163 | MetaVarName<"prefix">; |
| 164 | |
| 165 | def version : Flag<["-", "--"], "version">, |
| 166 | HelpText<"Print the version and exit.">; |