[llvm] r364118 - [llvm-objdump] Move --start-address >= --stop-address check out of the

Yuanfang Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 17:22:57 PDT 2019


Author: yuanfang
Date: Fri Jun 21 17:22:57 2019
New Revision: 364118

URL: http://llvm.org/viewvc/llvm-project?rev=364118&view=rev
Log:
[llvm-objdump] Move --start-address >= --stop-address check out of the
-d code.

Summary:
Move it into `main` function so the checking is effective for all actions
user may do with llvm-objdump; notably, -r and -s in addition to existing -d.

Match GNU behavior.

Reviewers: jhenderson, grimar, MaskRay, rupprecht

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63631

Modified:
    llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test
    llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp

Modified: llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test?rev=364118&r1=364117&r2=364118&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test (original)
+++ llvm/trunk/test/tools/llvm-objdump/X86/start-stop-address.test Fri Jun 21 17:22:57 2019
@@ -67,6 +67,6 @@
 
 // OUT-OF-RANGE-NOT: Disassembly
 
-// RUN: not llvm-objdump -d %t.out --start-address=0x40 --stop-address=0x3f 2>&1 | FileCheck %s --check-prefix ERRMSG
-// RUN: not llvm-objdump -d %t.out --start-address=0x40 --stop-address=0x40 2>&1 | FileCheck %s --check-prefix ERRMSG
+// RUN: not llvm-objdump %t.out --start-address=0x40 --stop-address=0x3f 2>&1 | FileCheck %s --check-prefix ERRMSG
+// RUN: not llvm-objdump %t.out --start-address=0x40 --stop-address=0x40 2>&1 | FileCheck %s --check-prefix ERRMSG
 // ERRMSG: start address should be less than stop address.

Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=364118&r1=364117&r2=364118&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Fri Jun 21 17:22:57 2019
@@ -1453,9 +1453,6 @@ static void disassembleObject(const Targ
 }
 
 static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
-  if (StartAddress >= StopAddress)
-    error("start address should be less than stop address");
-
   const Target *TheTarget = getTarget(Obj);
 
   // Package up features to be passed to target/subtarget
@@ -2116,6 +2113,9 @@ int main(int argc, char **argv) {
 
   cl::ParseCommandLineOptions(argc, argv, "llvm object file dumper\n");
 
+  if (StartAddress >= StopAddress)
+    error("start address should be less than stop address");
+
   ToolName = argv[0];
 
   // Defaults to a.out if no filenames specified.




More information about the llvm-commits mailing list