Index: llvm/trunk/test/tools/llvm-objcopy/objcopy-version.test =================================================================== --- llvm/trunk/test/tools/llvm-objcopy/objcopy-version.test +++ llvm/trunk/test/tools/llvm-objcopy/objcopy-version.test @@ -0,0 +1,4 @@ +# RUN: llvm-objcopy -version | FileCheck %s +# RUN: llvm-objcopy --version | FileCheck %s + +# CHECK: {{ version }} Index: llvm/trunk/test/tools/llvm-objcopy/strip-version.test =================================================================== --- llvm/trunk/test/tools/llvm-objcopy/strip-version.test +++ llvm/trunk/test/tools/llvm-objcopy/strip-version.test @@ -0,0 +1,4 @@ +# RUN: llvm-strip -version | FileCheck %s +# RUN: llvm-strip --version | FileCheck %s + +# CHECK: {{ version }} Index: llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td =================================================================== --- llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td +++ llvm/trunk/tools/llvm-objcopy/ObjcopyOpts.td @@ -107,6 +107,9 @@ "with '#'. Leading and trailing whitespace is stripped from each " "line. May be repeated to read symbols from many files.">; +def version : Flag<[ "-", "--" ], "version">, + HelpText<"Print the version and exit.">; + defm weaken_symbol : Eq<"weaken-symbol">, MetaVarName<"symbol">, HelpText<"Mark as weak">; Index: llvm/trunk/tools/llvm-objcopy/StripOpts.td =================================================================== --- llvm/trunk/tools/llvm-objcopy/StripOpts.td +++ llvm/trunk/tools/llvm-objcopy/StripOpts.td @@ -47,6 +47,10 @@ def discard_all : Flag<["-", "--"], "discard-all">, HelpText<"Remove all local symbols except file and section symbols">; + +def version : Flag<[ "-", "--" ], "version">, + HelpText<"Print the version and exit.">; + def x : Flag<["-"], "x">, Alias; Index: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp =================================================================== --- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp +++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp @@ -892,6 +892,11 @@ exit(0); } + if (InputArgs.hasArg(OBJCOPY_version)) { + cl::PrintVersionMessage(); + exit(0); + } + SmallVector Positional; for (auto Arg : InputArgs.filtered(OBJCOPY_UNKNOWN)) @@ -1019,6 +1024,11 @@ exit(0); } + if (InputArgs.hasArg(STRIP_version)) { + cl::PrintVersionMessage(); + exit(0); + } + SmallVector Positional; for (auto Arg : InputArgs.filtered(STRIP_UNKNOWN)) error("unknown argument '" + Arg->getAsString(InputArgs) + "'");