Index: test/tools/llvm-objcopy/strip-all.test =================================================================== --- test/tools/llvm-objcopy/strip-all.test +++ test/tools/llvm-objcopy/strip-all.test @@ -35,6 +35,12 @@ # RUN: llvm-strip --strip-all %t8 # RUN: cmp %t2 %t8 +# Verify that a positional output file leaves the input unchanged. +# RUN: cp %t %t10 +# RUN: llvm-strip --strip-all %t10 %t11 +# RUN: cmp %t %t10 +# RUN: cmp %t2 %t11 + !ELF FileHeader: Class: ELFCLASS64 Index: tools/llvm-objcopy/llvm-objcopy.cpp =================================================================== --- tools/llvm-objcopy/llvm-objcopy.cpp +++ tools/llvm-objcopy/llvm-objcopy.cpp @@ -648,8 +648,8 @@ CopyConfig Config; Config.InputFilename = Positional[0]; - Config.OutputFilename = - InputArgs.getLastArgValue(STRIP_output, Positional[0]); + Config.OutputFilename = InputArgs.getLastArgValue( + STRIP_output, Positional[Positional.size() - 1]); Config.StripDebug = InputArgs.hasArg(STRIP_strip_debug);