xref: /freebsd/contrib/llvm-project/llvm/tools/llvm-objcopy/CommonOpts.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
18bcb0991SDimitry Andricinclude "llvm/Option/OptParser.td"
28bcb0991SDimitry Andric
38bcb0991SDimitry Andricmulticlass Eq<string name, string help> {
48bcb0991SDimitry Andric  def NAME : Separate<["--"], name>;
58bcb0991SDimitry Andric  def NAME #_eq : Joined<["--"], name #"=">,
68bcb0991SDimitry Andric                  Alias<!cast<Separate>(NAME)>,
78bcb0991SDimitry Andric                  HelpText<help>;
88bcb0991SDimitry Andric}
98bcb0991SDimitry Andric
10*0fca6ea1SDimitry Andricdef grp_coff : OptionGroup<"kind">, HelpText<"OPTIONS (COFF specific)">;
11*0fca6ea1SDimitry Andricdef grp_macho : OptionGroup<"kind">, HelpText<"OPTIONS (Mach-O specific)">;
12*0fca6ea1SDimitry Andric
138bcb0991SDimitry Andricdef help : Flag<["--"], "help">;
148bcb0991SDimitry Andricdef h : Flag<["-"], "h">, Alias<help>;
158bcb0991SDimitry Andric
168bcb0991SDimitry Andricdef allow_broken_links
178bcb0991SDimitry Andric    : Flag<["--"], "allow-broken-links">,
188bcb0991SDimitry Andric      HelpText<"Allow the tool to remove sections even if it would leave "
198bcb0991SDimitry Andric               "invalid section references. The appropriate sh_link fields "
208bcb0991SDimitry Andric               "will be set to zero.">;
218bcb0991SDimitry Andric
228bcb0991SDimitry Andricdef enable_deterministic_archives
238bcb0991SDimitry Andric    : Flag<["--"], "enable-deterministic-archives">,
248bcb0991SDimitry Andric      HelpText<"Enable deterministic mode when operating on archives (use "
258bcb0991SDimitry Andric               "zero for UIDs, GIDs, and timestamps).">;
268bcb0991SDimitry Andricdef D : Flag<["-"], "D">,
278bcb0991SDimitry Andric        Alias<enable_deterministic_archives>,
288bcb0991SDimitry Andric        HelpText<"Alias for --enable-deterministic-archives">;
298bcb0991SDimitry Andric
308bcb0991SDimitry Andricdef disable_deterministic_archives
318bcb0991SDimitry Andric    : Flag<["--"], "disable-deterministic-archives">,
328bcb0991SDimitry Andric      HelpText<"Disable deterministic mode when operating on archives (use "
338bcb0991SDimitry Andric               "real values for UIDs, GIDs, and timestamps).">;
348bcb0991SDimitry Andricdef U : Flag<["-"], "U">,
358bcb0991SDimitry Andric        Alias<disable_deterministic_archives>,
368bcb0991SDimitry Andric        HelpText<"Alias for --disable-deterministic-archives">;
378bcb0991SDimitry Andric
388bcb0991SDimitry Andricdef preserve_dates : Flag<["--"], "preserve-dates">,
398bcb0991SDimitry Andric                     HelpText<"Preserve access and modification timestamps">;
408bcb0991SDimitry Andricdef p : Flag<["-"], "p">,
418bcb0991SDimitry Andric        Alias<preserve_dates>,
428bcb0991SDimitry Andric        HelpText<"Alias for --preserve-dates">;
438bcb0991SDimitry Andric
448bcb0991SDimitry Andricdef strip_all : Flag<["--"], "strip-all">,
45*0fca6ea1SDimitry Andric    HelpText<"For ELF, remove all symbols and non-alloc sections not within "
46*0fca6ea1SDimitry Andric             "segments, except for .gnu.warning*, .ARM.attribute, and the section name table. "
47*0fca6ea1SDimitry Andric             "For COFF and Mach-O, remove all symbols, debug sections, and relocations">;
488bcb0991SDimitry Andric
498bcb0991SDimitry Andricdef strip_all_gnu
508bcb0991SDimitry Andric    : Flag<["--"], "strip-all-gnu">,
51*0fca6ea1SDimitry Andric      HelpText<"Remove all symbols, debug sections and relocations. Compatible with GNU's --strip-all">;
528bcb0991SDimitry Andric
538bcb0991SDimitry Andricdef strip_debug : Flag<["--"], "strip-debug">,
548bcb0991SDimitry Andric                  HelpText<"Remove all debug sections">;
558bcb0991SDimitry Andricdef g : Flag<["-"], "g">,
568bcb0991SDimitry Andric        Alias<strip_debug>,
578bcb0991SDimitry Andric        HelpText<"Alias for --strip-debug">;
588bcb0991SDimitry Andric
598bcb0991SDimitry Andricdef strip_unneeded : Flag<["--"], "strip-unneeded">,
608bcb0991SDimitry Andric                     HelpText<"Remove all symbols not needed by relocations">;
618bcb0991SDimitry Andric
628bcb0991SDimitry Andricdefm remove_section : Eq<"remove-section", "Remove <section>">,
638bcb0991SDimitry Andric                      MetaVarName<"section">;
648bcb0991SDimitry Andricdef R : JoinedOrSeparate<["-"], "R">,
658bcb0991SDimitry Andric        Alias<remove_section>,
668bcb0991SDimitry Andric        HelpText<"Alias for --remove-section">;
678bcb0991SDimitry Andric
688bcb0991SDimitry Andricdef strip_sections
698bcb0991SDimitry Andric    : Flag<["--"], "strip-sections">,
70*0fca6ea1SDimitry Andric      HelpText<"Remove all section headers and all section data not within segments">;
718bcb0991SDimitry Andric
728bcb0991SDimitry Andricdefm strip_symbol : Eq<"strip-symbol", "Strip <symbol>">,
738bcb0991SDimitry Andric                    MetaVarName<"symbol">;
748bcb0991SDimitry Andricdef N : JoinedOrSeparate<["-"], "N">,
758bcb0991SDimitry Andric        Alias<strip_symbol>,
768bcb0991SDimitry Andric        HelpText<"Alias for --strip-symbol">;
778bcb0991SDimitry Andric
788bcb0991SDimitry Andricdefm keep_section : Eq<"keep-section", "Keep <section>">,
798bcb0991SDimitry Andric                    MetaVarName<"section">;
808bcb0991SDimitry Andric
81*0fca6ea1SDimitry Andricdefm keep_symbol : Eq<"keep-symbol", "When removing symbols, do not remove <symbol>">,
828bcb0991SDimitry Andric                   MetaVarName<"symbol">;
838bcb0991SDimitry Andricdef K : JoinedOrSeparate<["-"], "K">,
848bcb0991SDimitry Andric        Alias<keep_symbol>,
858bcb0991SDimitry Andric        HelpText<"Alias for --keep-symbol">;
868bcb0991SDimitry Andric
878bcb0991SDimitry Andricdef keep_file_symbols : Flag<["--"], "keep-file-symbols">,
88*0fca6ea1SDimitry Andric                        HelpText<"Keep symbols of type STT_FILE, even if they would otherwise be stripped">;
898bcb0991SDimitry Andric
90fe6060f1SDimitry Andricdef keep_undefined : Flag<["--"], "keep-undefined">,
91*0fca6ea1SDimitry Andric                        HelpText<"Do not remove undefined symbols">, Group<grp_macho>;
92fe6060f1SDimitry Andric
938bcb0991SDimitry Andricdef only_keep_debug
948bcb0991SDimitry Andric    : Flag<["--"], "only-keep-debug">,
95480093f4SDimitry Andric      HelpText<
96480093f4SDimitry Andric          "Produce a debug file as the output that only preserves contents of "
97480093f4SDimitry Andric          "sections useful for debugging purposes">;
988bcb0991SDimitry Andric
998bcb0991SDimitry Andricdef discard_locals : Flag<["--"], "discard-locals">,
100*0fca6ea1SDimitry Andric                     HelpText<"Remove local symbols starting with .L">;
1018bcb0991SDimitry Andricdef X : Flag<["-"], "X">,
1028bcb0991SDimitry Andric        Alias<discard_locals>,
1038bcb0991SDimitry Andric        HelpText<"Alias for --discard-locals">;
1048bcb0991SDimitry Andric
1058bcb0991SDimitry Andricdef discard_all
1068bcb0991SDimitry Andric    : Flag<["--"], "discard-all">,
107*0fca6ea1SDimitry Andric      HelpText<"Remove most local symbols. Different file formats may limit this to a subset. "
108*0fca6ea1SDimitry Andric      "For ELF, file and section symbols are not discarded. "
109*0fca6ea1SDimitry Andric      "Additionally, remove all debug sections">;
1108bcb0991SDimitry Andricdef x : Flag<["-"], "x">,
1118bcb0991SDimitry Andric        Alias<discard_all>,
1128bcb0991SDimitry Andric        HelpText<"Alias for --discard-all">;
1138bcb0991SDimitry Andric
1148bcb0991SDimitry Andricdef regex
1158bcb0991SDimitry Andric    : Flag<["--"], "regex">,
1168bcb0991SDimitry Andric      HelpText<"Permit regular expressions in name comparison">;
1178bcb0991SDimitry Andric
1188bcb0991SDimitry Andricdef version : Flag<["--"], "version">,
1198bcb0991SDimitry Andric              HelpText<"Print the version and exit.">;
1208bcb0991SDimitry Andricdef V : Flag<["-"], "V">,
1218bcb0991SDimitry Andric        Alias<version>,
1228bcb0991SDimitry Andric        HelpText<"Alias for --version">;
1238bcb0991SDimitry Andric
1248bcb0991SDimitry Andricdef wildcard
1258bcb0991SDimitry Andric    : Flag<["--"], "wildcard">,
1268bcb0991SDimitry Andric      HelpText<"Allow wildcard syntax for symbol-related flags. Incompatible "
1278bcb0991SDimitry Andric               "with --regex. Allows using '*' to match any number of "
1288bcb0991SDimitry Andric               "characters, '?' to match any single character, '\' to escape "
1298bcb0991SDimitry Andric               "special characters, and '[]' to define character classes. "
1308bcb0991SDimitry Andric               "Wildcards beginning with '!' will prevent a match, for example "
1318bcb0991SDimitry Andric               "\"-N '*' -N '!x'\" will strip all symbols except for \"x\".">;
1328bcb0991SDimitry Andricdef w : Flag<["-"], "w">, Alias<wildcard>, HelpText<"Alias for --wildcard">;
133