[llvm-objdump] Add '0x' prefix to a target displacement number to accent its hex...
authorSimon Atanasyan <simon@atanasyan.com>
Thu, 17 Mar 2016 10:43:44 +0000 (10:43 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Thu, 17 Mar 2016 10:43:44 +0000 (10:43 +0000)
It might be hard to recognize a hexadecimal number without '0x' prefix.
Besides that '0x' prefix corresponds to GNU objdump behaviour.

Differential Revision: http://reviews.llvm.org/D18207

llvm-svn: 263705

llvm/test/tools/llvm-objdump/hex-displacement.test [new file with mode: 0644]
llvm/tools/llvm-objdump/llvm-objdump.cpp

diff --git a/llvm/test/tools/llvm-objdump/hex-displacement.test b/llvm/test/tools/llvm-objdump/hex-displacement.test
new file mode 100644 (file)
index 0000000..38ab94b
--- /dev/null
@@ -0,0 +1,10 @@
+# Check that target displacement has '0x' prefix
+# to accent hex format of the number.
+
+# RUN: llvm-objdump -d %p/Inputs/export.dll.coff-i386 | FileCheck %s
+
+# CHECK:      exportfn2:
+# CHECK-NEXT: 10002010:       50      pushl   %eax
+# CHECK-NEXT: 10002011:       e8 00 00 00 00  calll   0 <exportfn2+0x6>
+# CHECK-NEXT: 10002016:       50      pushl   %eax
+# CHECK-NEXT: 10002017:       e8 00 00 00 00  calll   0 <exportfn2+0xC>
index 8a61716..eedfe30 100644 (file)
@@ -1142,7 +1142,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
                   outs() << " <" << TargetName;
                   uint64_t Disp = Target - TargetAddress;
                   if (Disp)
-                    outs() << '+' << utohexstr(Disp);
+                    outs() << "+0x" << utohexstr(Disp);
                   outs() << '>';
                 }
               }