[PATCH] D49537: Fix positional output argument for llvm-strip.

Stephen Hines via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 19 04:17:03 PDT 2018


srhines created this revision.
srhines added a reviewer: alexshap.
Herald added subscribers: llvm-commits, jakehehrlich.

This was accidentally clobbering the input file, and never creating the
output file when using a second positional input parameter.


Repository:
  rL LLVM

https://reviews.llvm.org/D49537

Files:
  test/tools/llvm-objcopy/strip-all.test
  tools/llvm-objcopy/llvm-objcopy.cpp


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);
 
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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49537.156231.patch
Type: text/x-patch
Size: 1038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180719/9098c5f2/attachment.bin>


More information about the llvm-commits mailing list