Index: llvm/trunk/tools/llvm-objcopy/CommonOpts.td =================================================================== --- llvm/trunk/tools/llvm-objcopy/CommonOpts.td +++ llvm/trunk/tools/llvm-objcopy/CommonOpts.td @@ -0,0 +1,113 @@ +include "llvm/Option/OptParser.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 the 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 + : Flag<["--"], "enable-deterministic-archives">, + HelpText<"Enable deterministic mode when operating on 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 operating on 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, + 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 strip_all_gnu + : Flag<["--"], "strip-all-gnu">, + HelpText<"Compatible with GNU's --strip-all">; + +def strip_debug : Flag<["--"], "strip-debug">, + HelpText<"Remove all debug sections">; +def g : Flag<["-"], "g">, + Alias, + HelpText<"Alias for --strip-debug">; + +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, + 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, + 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 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, + 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, + HelpText<"Alias for --discard-all">; + +def regex + : Flag<["--"], "regex">, + HelpText<"Permit regular expressions in name comparison">; + +def version : Flag<["--"], "version">, + HelpText<"Print the version and exit.">; +def V : Flag<["-"], "V">, + Alias, + HelpText<"Alias for --version">; Index: llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td =================================================================== --- llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td +++ llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td @@ -1,37 +1,29 @@ -include "llvm/Option/OptParser.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.">; +include "CommonOpts.td" 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 +38,10 @@ ", 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; - 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 +61,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 +78,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 +119,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 +136,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 +156,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 +176,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 +188,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 +201,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 +209,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: " Index: llvm/trunk/tools/llvm-objcopy/StripOpts.td =================================================================== --- llvm/trunk/tools/llvm-objcopy/StripOpts.td +++ llvm/trunk/tools/llvm-objcopy/StripOpts.td @@ -1,99 +1,17 @@ -include "llvm/Option/OptParser.td" +include "CommonOpts.td" -multiclass Eq { - def NAME : Separate<["--"], name>; - def NAME #_eq : Joined<["--"], name #"=">, - Alias(NAME)>, - HelpText; -} +def output : JoinedOrSeparate<["-"], "o">, HelpText<"Write output to ">, + MetaVarName<"">; -def help : Flag<["--"], "help">; -def h : Flag<["-"], "h">, Alias; - -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 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 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 ">; - -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 version : Flag<["--"], "version">, - HelpText<"Print the version and exit.">; -def V : Flag<["-"], "V">, Alias; +def d : Flag<["-"], "d">, + Alias, + HelpText<"Alias for --strip-debug">; +def S : Flag<["-"], "S">, + Alias, + HelpText<"Alias for --strip-debug">;