diff --git a/llvm/tools/llvm-objcopy/CommonAliases.td b/llvm/tools/llvm-objcopy/CommonAliases.td new file mode 100644 --- /dev/null +++ b/llvm/tools/llvm-objcopy/CommonAliases.td @@ -0,0 +1,20 @@ + +//===----------------------------------------------------------------------===// +// Aliases must be defined after what they alias. Initially, I had these +// aliases in CommonOpts.td, but putting them there causes CommonOpts.td:24:15: +// error: Variable not defined: 'enable_deterministic_archives' +// Alias, +// This error went away when I moved the "def D" from CommonOpts.td to here. +//===----------------------------------------------------------------------===// + +def D : Flag<["-"], "D">, + Alias, + HelpText<"Alias for --enable-deterministic-archives">; + +def U : Flag<["-"], "U">, + Alias, + HelpText<"Alias for --disable-deterministic-archives">; + +def g : Flag<["-"], "g">, + Alias, + HelpText<"Alias for --strip-debug">; diff --git a/llvm/tools/llvm-objcopy/StripOpts.td b/llvm/tools/llvm-objcopy/CommonOpts.td copy from llvm/tools/llvm-objcopy/StripOpts.td copy to llvm/tools/llvm-objcopy/CommonOpts.td --- a/llvm/tools/llvm-objcopy/StripOpts.td +++ b/llvm/tools/llvm-objcopy/CommonOpts.td @@ -10,71 +10,70 @@ def help : Flag<["--"], "help">; def h : Flag<["-"], "h">, Alias; -def allow_broken_links +class allow_broken_links : Flag<["--"], "allow-broken-links">, - HelpText<"Allow llvm-strip to remove sections even if it would leave " + HelpText<"Allow "#tool#" to remove sections even if it would leave " "invalid section references. The appropriate sh_link fields " "will be set to zero.">; -def enable_deterministic_archives +class enable_deterministic_archives : Flag<["--"], "enable-deterministic-archives">, - HelpText<"Enable deterministic mode when stripping archives (use zero " + HelpText<"Enable deterministic mode when "#action#" archives (use zero " "for UIDs, GIDs, and timestamps).">; -def D : Flag<["-"], "D">, - Alias, - HelpText<"Alias for --enable-deterministic-archives">; -def disable_deterministic_archives +class disable_deterministic_archives : Flag<["--"], "disable-deterministic-archives">, - HelpText<"Disable deterministic mode when stripping archives (use real " + HelpText<"Disable deterministic mode when "#action#" archives (use real " "values for UIDs, GIDs, and timestamps).">; -def U : Flag<["-"], "U">, - Alias, - HelpText<"Alias for --disable-deterministic-archives">; - -def output : JoinedOrSeparate<["-"], "o">, HelpText<"Write output to ">; def preserve_dates : Flag<["--"], "preserve-dates">, HelpText<"Preserve access and modification timestamps">; -def p : Flag<["-"], "p">, Alias; +def p : Flag<["-"], "p">, + Alias, + HelpText<"Alias for --preserve-dates">; def strip_all : Flag<["--"], "strip-all">, HelpText<"Remove non-allocated sections outside segments. " ".gnu.warning* sections are not removed">; -def s : Flag<["-"], "s">, Alias; -def no_strip_all : Flag<["--"], "no-strip-all">, - HelpText<"Disable --strip-all">; -def strip_all_gnu : Flag<["--"], "strip-all-gnu">, - HelpText<"Compatible with GNU strip's --strip-all">; +class strip_all_gnu + : Flag<["--"], "strip-all-gnu">, + HelpText<"Compatible with GNU "#tool#"'s --strip-all">; + def strip_debug : Flag<["--"], "strip-debug">, - HelpText<"Remove debugging symbols only">; -def d : Flag<["-"], "d">, Alias; -def g : Flag<["-"], "g">, Alias; -def S : Flag<["-"], "S">, Alias; -def strip_sections - : Flag<["--"], "strip-sections">, - HelpText<"Remove all section headers and all sections not in segments">; + HelpText<"Remove all debug sections">; + def strip_unneeded : Flag<["--"], "strip-unneeded">, HelpText<"Remove all symbols not needed by relocations">; defm remove_section : Eq<"remove-section", "Remove
">, MetaVarName<"section">; -def R : JoinedOrSeparate<["-"], "R">, Alias; +def R : JoinedOrSeparate<["-"], "R">, + Alias, + HelpText<"Alias for --remove-section">; + +def strip_sections + : Flag<["--"], "strip-sections">, + HelpText<"Remove all section headers and all sections not in segments">; defm strip_symbol : Eq<"strip-symbol", "Strip ">, MetaVarName<"symbol">; -def N : JoinedOrSeparate<["-"], "N">, Alias; +def N : JoinedOrSeparate<["-"], "N">, + Alias, + HelpText<"Alias for --strip-symbol">; defm keep_section : Eq<"keep-section", "Keep
">, MetaVarName<"section">; + defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol ">, MetaVarName<"symbol">; +def K : JoinedOrSeparate<["-"], "K">, + Alias, + HelpText<"Alias for --keep-symbol">; + def keep_file_symbols : Flag<["--"], "keep-file-symbols">, HelpText<"Do not remove file symbols">; -def K : JoinedOrSeparate<["-"], "K">, Alias; - def only_keep_debug : Flag<["--"], "only-keep-debug">, HelpText<"Clear sections that would not be stripped by --strip-debug. " @@ -83,12 +82,16 @@ def discard_locals : Flag<["--"], "discard-locals">, HelpText<"Remove compiler-generated local symbols, (e.g. " "symbols starting with .L)">; -def X : Flag<["-"], "X">, Alias; +def X : Flag<["-"], "X">, + Alias, + HelpText<"Alias for --discard-locals">; def discard_all : Flag<["--"], "discard-all">, HelpText<"Remove all local symbols except file and section symbols">; -def x : Flag<["-"], "x">, Alias; +def x : Flag<["-"], "x">, + Alias, + HelpText<"Alias for --discard-all">; def regex : Flag<["--"], "regex">, @@ -96,4 +99,6 @@ def version : Flag<["--"], "version">, HelpText<"Print the version and exit.">; -def V : Flag<["-"], "V">, Alias; +def V : Flag<["-"], "V">, + Alias, + HelpText<"Alias for --version">; diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td --- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td +++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td @@ -1,37 +1,31 @@ -include "llvm/Option/OptParser.td" +include "CommonOpts.td" -multiclass Eq { - def NAME : Separate<["--"], name>; - def NAME #_eq : Joined<["--"], name #"=">, - Alias(NAME)>, - HelpText; -} - -def help : Flag<["--"], "help">; -def h : Flag<["-"], "h">, Alias; - -def allow_broken_links - : Flag<["--"], "allow-broken-links">, - HelpText<"Allow llvm-objcopy to remove sections even if it would leave " - "invalid section references. The appropriate sh_link fields " - "will be set to zero.">; +def allow_broken_links : allow_broken_links<"llvm-objcopy">; defm binary_architecture : Eq<"binary-architecture", "Used when transforming an architecture-less " "format (such as binary) to another format">; -def B : JoinedOrSeparate<["-"], "B">, Alias; +def B : JoinedOrSeparate<["-"], "B">, + Alias, + HelpText<"Alias for --binary-architecture">; defm target : Eq<"target", "Format of the input and output file">, Values<"binary">; -def F : JoinedOrSeparate<["-"], "F">, Alias; +def F : JoinedOrSeparate<["-"], "F">, + Alias, + HelpText<"Alias for --target">; defm input_target : Eq<"input-target", "Format of the input file">, Values<"binary">; -def I : JoinedOrSeparate<["-"], "I">, Alias; +def I : JoinedOrSeparate<["-"], "I">, + Alias, + HelpText<"Alias for --input-target">; defm output_target : Eq<"output-target", "Format of the output file">, Values<"binary">; -def O : JoinedOrSeparate<["-"], "O">, Alias; +def O : JoinedOrSeparate<["-"], "O">, + Alias, + HelpText<"Alias for --output-target">; def compress_debug_sections : Flag<["--"], "compress-debug-sections">; def compress_debug_sections_eq @@ -46,34 +40,16 @@ ", then strip-dwo on the input file">, MetaVarName<"dwo-file">; -def enable_deterministic_archives - : Flag<["--"], "enable-deterministic-archives">, - HelpText<"Enable deterministic mode when copying archives (use zero for " - "UIDs, GIDs, and timestamps).">; -def D : Flag<["-"], "D">, - Alias, - HelpText<"Alias for --enable-deterministic-archives">; - -def disable_deterministic_archives - : Flag<["--"], "disable-deterministic-archives">, - HelpText<"Disable deterministic mode when copying archives (use real " - "values for UIDs, GIDs, and timestamps).">; -def U : Flag<["-"], "U">, - Alias, - HelpText<"Alias for --disable-deterministic-archives">; - -def preserve_dates : Flag<["--"], "preserve-dates">, - HelpText<"Preserve access and modification timestamps">; -def p : Flag<["-"], "p">, Alias; +def enable_deterministic_archives : enable_deterministic_archives<"copying">; + +def disable_deterministic_archives : disable_deterministic_archives<"copying">; + +def strip_all_gnu : strip_all_gnu<"objcopy">; defm add_gnu_debuglink : Eq<"add-gnu-debuglink", "Add a .gnu_debuglink for ">, MetaVarName<"debug-file">; -defm remove_section : Eq<"remove-section", "Remove
">, - MetaVarName<"section">; -def R : JoinedOrSeparate<["-"], "R">, Alias; - defm rename_section : Eq<"rename-section", "Renames a section from old to new, optionally with specified flags. " @@ -93,11 +69,11 @@ "symbols from many files.">, MetaVarName<"filename">; -defm keep_section : Eq<"keep-section", "Keep
">, - MetaVarName<"section">; defm only_section : Eq<"only-section", "Remove all but
">, MetaVarName<"section">; -def j : JoinedOrSeparate<["-"], "j">, Alias; +def j : JoinedOrSeparate<["-"], "j">, + Alias, + HelpText<"Alias for --only-section">; defm add_section : Eq<"add-section", "Make a section named
with the contents of .">, @@ -110,26 +86,14 @@ "rom, share, contents, merge, strings.">, MetaVarName<"section=flag1[,flag2,...]">; -def strip_all : Flag<["--"], "strip-all">, - HelpText<"Remove non-allocated sections outside segments. " - ".gnu.warning* sections are not removed">; -def S : Flag<["-"], "S">, Alias; -def strip_all_gnu : Flag<["--"], "strip-all-gnu">, - HelpText<"Compatible with GNU objcopy's --strip-all">; -def strip_debug : Flag<["--"], "strip-debug">, - HelpText<"Remove all debug information">; -def g : Flag<["-"], "g">, Alias, - HelpText<"Alias for --strip-debug">; +def S : Flag<["-"], "S">, + Alias, + HelpText<"Alias for --strip-all">; def strip_dwo : Flag<["--"], "strip-dwo">, HelpText<"Remove all DWARF .dwo sections from file">; -def strip_sections - : Flag<["--"], "strip-sections">, - HelpText<"Remove all section headers and all sections not in segments">; def strip_non_alloc : Flag<["--"], "strip-non-alloc">, HelpText<"Remove all non-allocated sections outside segments">; -def strip_unneeded : Flag<["--"], "strip-unneeded">, - HelpText<"Remove all symbols not needed by relocations">; defm strip_unneeded_symbol : Eq<"strip-unneeded-symbol", "Remove symbol if it is not needed by relocations">, @@ -163,7 +127,9 @@ "Reads a list of symbols from and marks them local.">, MetaVarName<"filename">; -def L : JoinedOrSeparate<["-"], "L">, Alias; +def L : JoinedOrSeparate<["-"], "L">, + Alias, + HelpText<"Alias for --localize-symbol">; defm globalize_symbol : Eq<"globalize-symbol", "Mark as global">, MetaVarName<"symbol">; @@ -178,7 +144,9 @@ "Convert all symbols except to local. May be repeated to " "convert all except a set of symbols to local.">, MetaVarName<"symbol">; -def G : JoinedOrSeparate<["-"], "G">, Alias; +def G : JoinedOrSeparate<["-"], "G">, + Alias, + HelpText<"Alias for --keep-global-symbol">; defm keep_global_symbols : Eq<"keep-global-symbols", @@ -196,31 +164,17 @@ "Reads a list of symbols from and marks them weak.">, MetaVarName<"filename">; -def W : JoinedOrSeparate<["-"], "W">, Alias; +def W : JoinedOrSeparate<["-"], "W">, + Alias, + HelpText<"Alias for --weaken-symbol">; def weaken : Flag<["--"], "weaken">, HelpText<"Mark all global symbols as weak">; -def discard_locals : Flag<["--"], "discard-locals">, - HelpText<"Remove compiler-generated local symbols, (e.g. " - "symbols starting with .L)">; -def X : Flag<["-"], "X">, Alias; - -def discard_all - : Flag<["--"], "discard-all">, - HelpText<"Remove all local symbols except file and section symbols">; -def x : Flag<["-"], "x">, Alias; -defm strip_symbol : Eq<"strip-symbol", "Remove symbol ">, - MetaVarName<"symbol">; defm strip_symbols : Eq<"strip-symbols", "Reads a list of symbols from and removes them.">, MetaVarName<"filename">; -def N : JoinedOrSeparate<["-"], "N">, Alias; -defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol ">, - MetaVarName<"symbol">; -def K : JoinedOrSeparate<["-"], "K">, Alias; - defm keep_symbols : Eq<"keep-symbols", "Reads a list of symbols from and runs as if " @@ -230,13 +184,6 @@ "be repeated to read symbols from many files.">, MetaVarName<"filename">; -def only_keep_debug - : Flag<["--"], "only-keep-debug">, - HelpText<"Clear sections that would not be stripped by --strip-debug. " - "Currently only implemented for COFF.">; - -def keep_file_symbols : Flag<["--"], "keep-file-symbols">, - HelpText<"Do not remove file symbols">; defm dump_section : Eq<"dump-section", "Dump contents of section named
into file ">, @@ -249,9 +196,6 @@ : Eq<"prefix-alloc-sections", "Add to the start of every allocated section name">, MetaVarName<"prefix">; -def version : Flag<["--"], "version">, - HelpText<"Print the version and exit.">; -def V : Flag<["-"], "V">, Alias; defm build_id_link_dir : Eq<"build-id-link-dir", "Set directory for --build-id-link-input and " "--build-id-link-output to ">, @@ -265,10 +209,6 @@ "name derived from hex build ID">, MetaVarName<"suffix">; -def regex - : Flag<["--"], "regex">, - HelpText<"Permit regular expressions in name comparison">; - defm set_start : Eq<"set-start", "Set the start address to . Overrides " "any previous --change-start or --adjust-start values.">, MetaVarName<"addr">; @@ -277,7 +217,8 @@ "cumulatively.">, MetaVarName<"incr">; def adjust_start : JoinedOrSeparate<["--"], "adjust-start">, - Alias; + Alias, + HelpText<"Alias for --change-start">; defm add_symbol : Eq<"add-symbol", "Add new symbol to .symtab. Accepted flags: " @@ -286,3 +227,5 @@ "compatibility: debug, constructor, warning, indirect, synthetic, " "unique-object, before.">, MetaVarName<"name=[section:]value[,flags]">; + +include "CommonAliases.td" diff --git a/llvm/tools/llvm-objcopy/StripOpts.td b/llvm/tools/llvm-objcopy/StripOpts.td --- a/llvm/tools/llvm-objcopy/StripOpts.td +++ b/llvm/tools/llvm-objcopy/StripOpts.td @@ -1,99 +1,27 @@ -include "llvm/Option/OptParser.td" +include "CommonOpts.td" -multiclass Eq { - def NAME : Separate<["--"], name>; - def NAME #_eq : Joined<["--"], name #"=">, - Alias(NAME)>, - HelpText; -} +def allow_broken_links : allow_broken_links<"llvm-strip">; -def help : Flag<["--"], "help">; -def h : Flag<["-"], "h">, Alias; +def enable_deterministic_archives : enable_deterministic_archives<"stripping">; -def allow_broken_links - : Flag<["--"], "allow-broken-links">, - HelpText<"Allow llvm-strip to remove sections even if it would leave " - "invalid section references. The appropriate sh_link fields " - "will be set to zero.">; +def disable_deterministic_archives : disable_deterministic_archives<"stripping">; -def enable_deterministic_archives - : Flag<["--"], "enable-deterministic-archives">, - HelpText<"Enable deterministic mode when stripping archives (use zero " - "for UIDs, GIDs, and timestamps).">; -def D : Flag<["-"], "D">, - Alias, - HelpText<"Alias for --enable-deterministic-archives">; +def strip_all_gnu : strip_all_gnu<"strip">; -def disable_deterministic_archives - : Flag<["--"], "disable-deterministic-archives">, - HelpText<"Disable deterministic mode when stripping archives (use real " - "values for UIDs, GIDs, and timestamps).">; -def U : Flag<["-"], "U">, - Alias, - HelpText<"Alias for --disable-deterministic-archives">; +def output : JoinedOrSeparate<["-"], "o">, HelpText<"Write output to ">, + MetaVarName<"">; -def output : JoinedOrSeparate<["-"], "o">, HelpText<"Write output to ">; - -def preserve_dates : Flag<["--"], "preserve-dates">, - HelpText<"Preserve access and modification timestamps">; -def p : Flag<["-"], "p">, Alias; - -def strip_all : Flag<["--"], "strip-all">, - HelpText<"Remove non-allocated sections outside segments. " - ".gnu.warning* sections are not removed">; -def s : Flag<["-"], "s">, Alias; +def s : Flag<["-"], "s">, + Alias, + HelpText<"Alias for --strip-all">; def no_strip_all : Flag<["--"], "no-strip-all">, HelpText<"Disable --strip-all">; -def strip_all_gnu : Flag<["--"], "strip-all-gnu">, - HelpText<"Compatible with GNU strip's --strip-all">; -def strip_debug : Flag<["--"], "strip-debug">, - HelpText<"Remove debugging symbols only">; -def d : Flag<["-"], "d">, Alias; -def g : Flag<["-"], "g">, Alias; -def S : Flag<["-"], "S">, Alias; -def strip_sections - : Flag<["--"], "strip-sections">, - HelpText<"Remove all section headers and all sections not in segments">; -def strip_unneeded : Flag<["--"], "strip-unneeded">, - HelpText<"Remove all symbols not needed by relocations">; - -defm remove_section : Eq<"remove-section", "Remove
">, - MetaVarName<"section">; -def R : JoinedOrSeparate<["-"], "R">, Alias; - -defm strip_symbol : Eq<"strip-symbol", "Strip ">, - MetaVarName<"symbol">; -def N : JoinedOrSeparate<["-"], "N">, Alias; - -defm keep_section : Eq<"keep-section", "Keep
">, - MetaVarName<"section">; -defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol ">, - MetaVarName<"symbol">; -def keep_file_symbols : Flag<["--"], "keep-file-symbols">, - HelpText<"Do not remove file symbols">; - -def K : JoinedOrSeparate<["-"], "K">, Alias; - -def only_keep_debug - : Flag<["--"], "only-keep-debug">, - HelpText<"Clear sections that would not be stripped by --strip-debug. " - "Currently only implemented for COFF.">; - -def discard_locals : Flag<["--"], "discard-locals">, - HelpText<"Remove compiler-generated local symbols, (e.g. " - "symbols starting with .L)">; -def X : Flag<["-"], "X">, Alias; - -def discard_all - : Flag<["--"], "discard-all">, - HelpText<"Remove all local symbols except file and section symbols">; -def x : Flag<["-"], "x">, Alias; - -def regex - : Flag<["--"], "regex">, - HelpText<"Permit regular expressions in name comparison">; +def d : Flag<["-"], "d">, + Alias, + HelpText<"Alias for --strip-debug">; +def S : Flag<["-"], "S">, + Alias, + HelpText<"Alias for --strip-debug">; -def version : Flag<["--"], "version">, - HelpText<"Print the version and exit.">; -def V : Flag<["-"], "V">, Alias; +include "CommonAliases.td"