[llvm-objcopy] Fix exit code

Set the exit code to 1 if no arguments are specified.

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D46547

llvm-svn: 331776
diff --git a/llvm/test/tools/llvm-objcopy/help-message.test b/llvm/test/tools/llvm-objcopy/help-message.test
new file mode 100644
index 0000000..5f49967
--- /dev/null
+++ b/llvm/test/tools/llvm-objcopy/help-message.test
@@ -0,0 +1,8 @@
+# RUN: llvm-objcopy --help | FileCheck --check-prefix=CHECK-OBJCOPY %s
+# RUN: not llvm-objcopy 2>&1 | FileCheck --check-prefix=CHECK-OBJCOPY %s
+
+# RUN: llvm-strip --help | FileCheck --check-prefix=CHECK-STRIP %s
+# RUN: not llvm-strip 2>&1 | FileCheck --check-prefix=CHECK-STRIP %s
+
+# CHECK-OBJCOPY: USAGE: llvm-objcopy
+# CHECK-STRIP:   USAGE: llvm-strip
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index 295c9bf..1cfcb06 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -409,8 +409,13 @@
   unsigned MissingArgumentIndex, MissingArgumentCount;
   llvm::opt::InputArgList InputArgs =
       T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
-
-  if (InputArgs.size() == 0 || InputArgs.hasArg(OBJCOPY_help)) {
+  
+  if (InputArgs.size() == 0) {
+    T.PrintHelp(errs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool");
+    exit(1);
+  }
+  
+  if (InputArgs.hasArg(OBJCOPY_help)) {
     T.PrintHelp(outs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool");
     exit(0);
   }
@@ -484,7 +489,12 @@
   llvm::opt::InputArgList InputArgs =
       T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
 
-  if (InputArgs.size() == 0 || InputArgs.hasArg(STRIP_help)) {
+  if (InputArgs.size() == 0) {
+    T.PrintHelp(errs(), "llvm-strip <input> [ <output> ]", "strip tool");
+    exit(1);
+  }
+  
+  if (InputArgs.hasArg(STRIP_help)) {
     T.PrintHelp(outs(), "llvm-strip <input> [ <output> ]", "strip tool");
     exit(0);
   }