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> { |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 4 | def NAME: Separate<["--", "-"], name>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 5 | def NAME # _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>, |
| 6 | HelpText<help>; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 7 | } |
| 8 | |
| 9 | def help : Flag<["-", "--"], "help">; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 10 | defm binary_architecture |
| 11 | : Eq<"binary-architecture", "Used when transforming an architecture-less " |
| 12 | "format (such as binary) to another format">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 13 | def B : JoinedOrSeparate<["-"], "B">, |
| 14 | Alias<binary_architecture>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 15 | defm target : Eq<"target", "Format of the input and output file">, |
Jordan Rupprecht | bb4588e | 2018-10-12 00:36:01 +0000 | [diff] [blame] | 16 | Values<"binary">; |
| 17 | def F : JoinedOrSeparate<[ "-" ], "F">, Alias<target>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 18 | defm input_target : Eq<"input-target", "Format of the input file">, |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 19 | Values<"binary">; |
Jordan Rupprecht | 175ef5f | 2018-08-01 20:59:39 +0000 | [diff] [blame] | 20 | def I : JoinedOrSeparate<[ "-" ], "I">, Alias<input_target>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 21 | defm output_target : Eq<"output-target", "Format of the output file">, |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 22 | Values<"binary">; |
Puyan Lotfi | 99124cc | 2018-09-07 08:10:22 +0000 | [diff] [blame] | 23 | def compress_debug_sections : Flag<["--", "-"], "compress-debug-sections">; |
| 24 | def 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 Lotfi | af04864 | 2018-10-01 10:29:41 +0000 | [diff] [blame] | 29 | def decompress_debug_sections : Flag<["-", "--"], "decompress-debug-sections">, |
| 30 | HelpText<"Decompress DWARF debug sections.">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 31 | def O : JoinedOrSeparate<["-"], "O">, |
| 32 | Alias<output_target>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 33 | defm 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 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 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 43 | defm add_gnu_debuglink : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for <debug-file>">, |
| 44 | MetaVarName<"debug-file">; |
| 45 | defm remove_section : Eq<"remove-section", "Remove <section>">, |
| 46 | MetaVarName<"section">; |
Jordan Rupprecht | d67c1e1 | 2018-08-01 16:23:22 +0000 | [diff] [blame] | 47 | defm rename_section |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 48 | : 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,...]">; |
| 53 | defm redefine_symbol : Eq<"redefine-sym", "Change the name of a symbol old to new">, |
| 54 | MetaVarName<"old=new">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 55 | def R : JoinedOrSeparate<["-"], "R">, |
| 56 | Alias<remove_section>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 57 | defm keep : Eq<"keep", "Keep <section>">, |
| 58 | MetaVarName<"section">; |
| 59 | defm only_keep : Eq<"only-keep", "Remove all but <section>">, |
| 60 | MetaVarName<"section">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 61 | def j : JoinedOrSeparate<["-"], "j">, |
| 62 | Alias<only_keep>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 63 | defm add_section |
| 64 | : Eq<"add-section", |
| 65 | "Make a section named <section> with the contents of <file>.">, |
| 66 | MetaVarName<"section=file">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 67 | def strip_all : Flag<["-", "--"], "strip-all">, |
Alexander Shaposhnikov | b3bfd3b | 2018-04-24 21:44:13 +0000 | [diff] [blame] | 68 | HelpText<"Remove non-allocated sections other than .gnu.warning* sections">; |
Jake Ehrlich | 5e49846 | 2018-10-09 21:14:09 +0000 | [diff] [blame] | 69 | def S : Flag<["-"], "S">, |
| 70 | Alias<strip_all>; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 71 | def strip_all_gnu : Flag<["-", "--"], "strip-all-gnu">, |
| 72 | HelpText<"Compaitable with GNU objcopy's --strip-all">; |
| 73 | def strip_debug : Flag<["-", "--"], "strip-debug">, |
Alexander Shaposhnikov | b3bfd3b | 2018-04-24 21:44:13 +0000 | [diff] [blame] | 74 | HelpText<"Remove all debug information">; |
Alexander Shaposhnikov | d688479 | 2018-04-24 05:43:32 +0000 | [diff] [blame] | 75 | def strip_dwo : Flag<["-", "--"], "strip-dwo">, |
| 76 | HelpText<"Remove all DWARF .dwo sections from file">; |
| 77 | def strip_sections : Flag<["-", "--"], "strip-sections">, |
| 78 | HelpText<"Remove all section headers">; |
| 79 | def strip_non_alloc : Flag<["-", "--"], "strip-non-alloc">, |
| 80 | HelpText<"Remove all non-allocated sections">; |
| 81 | def extract_dwo : Flag<["-", "--"], "extract-dwo">, |
| 82 | HelpText<"Remove all sections that are not DWARF .dwo sections from file">; |
| 83 | def localize_hidden : Flag<["-", "--"], "localize-hidden">, |
| 84 | HelpText<"Mark all symbols that have hidden or internal visibility as local">; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 85 | defm localize_symbol : Eq<"localize-symbol", "Mark <symbol> as local">, |
| 86 | MetaVarName<"symbol">; |
Paul Semel | b492494 | 2018-04-26 17:44:43 +0000 | [diff] [blame] | 87 | def L : JoinedOrSeparate<["-"], "L">, |
| 88 | Alias<localize_symbol>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 89 | defm globalize_symbol : Eq<"globalize-symbol", "Mark <symbol> as global">, |
| 90 | MetaVarName<"symbol">; |
Jordan Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 91 | |
| 92 | defm keep_global_symbol |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 93 | : 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 Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 96 | def G : JoinedOrSeparate<[ "-" ], "G">, Alias<keep_global_symbol>; |
| 97 | |
| 98 | defm keep_global_symbols |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 99 | : 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 Rupprecht | be8ebcc | 2018-08-17 22:34:48 +0000 | [diff] [blame] | 106 | |
Jordan Rupprecht | 7b1c816 | 2018-09-21 00:47:31 +0000 | [diff] [blame] | 107 | def version : Flag<[ "-", "--" ], "version">, |
| 108 | HelpText<"Print the version and exit.">; |
| 109 | |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 110 | defm weaken_symbol : Eq<"weaken-symbol", "Mark <symbol> as weak">, |
| 111 | MetaVarName<"symbol">; |
Paul Semel | 3a8a56b | 2018-04-27 19:16:27 +0000 | [diff] [blame] | 112 | def W : JoinedOrSeparate<["-"], "W">, |
| 113 | Alias<weaken_symbol>; |
Paul Semel | 2c0510f | 2018-05-02 20:14:49 +0000 | [diff] [blame] | 114 | def weaken : Flag<["-", "--"], "weaken">, |
| 115 | HelpText<"Mark all global symbols as weak">; |
Paul Semel | 41695f8 | 2018-05-02 20:19:22 +0000 | [diff] [blame] | 116 | def discard_all : Flag<["-", "--"], "discard-all">, |
| 117 | HelpText<"Remove all local symbols except file and section symbols">; |
| 118 | def x : Flag<["-"], "x">, |
| 119 | Alias<discard_all>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 120 | defm strip_symbol : Eq<"strip-symbol", "Remove symbol <symbol>">, |
| 121 | MetaVarName<"symbol">; |
Paul Semel | 4246a46 | 2018-05-09 21:36:54 +0000 | [diff] [blame] | 122 | def N : JoinedOrSeparate<["-"], "N">, |
| 123 | Alias<strip_symbol>; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 124 | defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">, |
| 125 | MetaVarName<"symbol">; |
Paul Semel | 5d97c82 | 2018-05-15 14:09:37 +0000 | [diff] [blame] | 126 | def K : JoinedOrSeparate<["-"], "K">, |
| 127 | Alias<keep_symbol>; |
Jake Ehrlich | e40398a | 2018-05-15 20:53:53 +0000 | [diff] [blame] | 128 | def only_keep_debug : Flag<["-", "--"], "only-keep-debug">, |
| 129 | HelpText<"Currently ignored. Only for compaitability with GNU objcopy.">; |
Paul Semel | 99dda0b | 2018-05-25 11:01:25 +0000 | [diff] [blame] | 130 | def strip_unneeded : Flag<["-", "--"], "strip-unneeded">, |
| 131 | HelpText<"Remove all symbols not needed by relocations">; |
Paul Semel | cf51c80 | 2018-05-26 08:10:37 +0000 | [diff] [blame] | 132 | def keep_file_symbols : Flag<["-", "--"], "keep-file-symbols">, |
| 133 | HelpText<"Do not remove file symbols">; |
Fangrui Song | ab205a3 | 2018-11-01 17:20:40 +0000 | [diff] [blame^] | 134 | defm dump_section : Eq<"dump-section", "Dump contents of section named <section> into file <file>">, |
| 135 | MetaVarName<"section=file">; |
| 136 | defm prefix_symbols : Eq<"prefix-symbols", "Add <prefix> to the start of every symbol name">, |
| 137 | MetaVarName<"prefix">; |