[llvm-readobj] Print error when executed with no input files
This patch changes llvm-readelf (and llvm-readobj for consistency)
behavior to print an error when executed with no input files.
Reading from stdin can be achieved via a '-' for the input
object.
Fixes https://bugs.llvm.org/show_bug.cgi?id=46400
Differential Revision: https://reviews.llvm.org/D83704
Reviewed by: jhenderson, MaskRay, sbc, jyknight
diff --git a/llvm/test/tools/llvm-readobj/basic.test b/llvm/test/tools/llvm-readobj/basic.test
index 89962c3..5b31795 100644
--- a/llvm/test/tools/llvm-readobj/basic.test
+++ b/llvm/test/tools/llvm-readobj/basic.test
@@ -4,6 +4,11 @@
ENOENT: llvm-[[TOOL]]{{(\.exe)?}}: error: '{{.*}}.blah': {{[Nn]}}o such file or directory
+# Test case with no input file.
+RUN: not llvm-readobj 2>&1 | FileCheck %s --check-prefix=NO-FILE
+RUN: not llvm-readelf 2>&1 | FileCheck %s --check-prefix=NO-FILE
+NO-FILE: error: no input files specified
+
# Test case where input file is too small to be a recognised object file.
RUN: touch %t.empty
RUN: not llvm-readobj %t.empty 2>&1 | FileCheck --check-prefix=EMPTY %s