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