Fix printing of 64 bit values and make test more strict.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 1 Oct 2015 17:57:31 +0000 (17:57 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 1 Oct 2015 17:57:31 +0000 (17:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249043 91177308-0d34-0410-b5e6-96231b3b80d8

test/Object/readobj-shared-object.test
tools/llvm-readobj/ELFDumper.cpp

index 508caca9717dc0d5dafff8db5359a4fa84e68b15..173581e60c39b19373eb694e8d5dd4826c35a2c8 100644 (file)
@@ -300,18 +300,32 @@ ELF:     Section: Absolute (0xFFF1)
 ELF:   }
 ELF: ]
 
-ELF: DynamicSection [ (9 entries)
-ELF:   Tag        Type                 Name/Value
-ELF:   00000001 NEEDED               SharedLibrary (libc.so.6)
-ELF:   00000001 NEEDED               SharedLibrary (libm.so.6)
-ELF:   0000000E SONAME               LibrarySoname (libfoo.so)
-ELF:   00000004 HASH                 {{[0-9a-f]+}}
-ELF:   00000005 STRTAB               {{[0-9a-f]+}}
-ELF:   00000006 SYMTAB               {{[0-9a-f]+}}
-ELF:   0000000A STRSZ                {{[0-9]+}} (bytes)
-ELF:   0000000B SYMENT               {{[0-9]+}} (bytes)
-ELF:   00000000 NULL                 0x0
-ELF: ]
+ELF32: DynamicSection [ (9 entries)
+ELF32:   Tag        Type                 Name/Value
+ELF32:   0x00000001 NEEDED               SharedLibrary (libc.so.6)
+ELF32:   0x00000001 NEEDED               SharedLibrary (libm.so.6)
+ELF32:   0x0000000E SONAME               LibrarySoname (libfoo.so)
+ELF32:   0x00000004 HASH                 {{[0-9a-f]+}}
+ELF32:   0x00000005 STRTAB               {{[0-9a-f]+}}
+ELF32:   0x00000006 SYMTAB               {{[0-9a-f]+}}
+ELF32:   0x0000000A STRSZ                {{[0-9]+}} (bytes)
+ELF32:   0x0000000B SYMENT               {{[0-9]+}} (bytes)
+ELF32:   0x00000000 NULL                 0x0
+ELF32: ]
+
+ELF64: DynamicSection [ (9 entries)
+ELF64:   Tag        Type                 Name/Value
+ELF64:   0x0000000000000001 NEEDED               SharedLibrary (libc.so.6)
+ELF64:   0x0000000000000001 NEEDED               SharedLibrary (libm.so.6)
+ELF64:   0x000000000000000E SONAME               LibrarySoname (libfoo.so)
+ELF64:   0x0000000000000004 HASH                 {{[0-9a-f]+}}
+ELF64:   0x0000000000000005 STRTAB               {{[0-9a-f]+}}
+ELF64:   0x0000000000000006 SYMTAB               {{[0-9a-f]+}}
+ELF64:   0x000000000000000A STRSZ                {{[0-9]+}} (bytes)
+ELF64:   0x000000000000000B SYMENT               {{[0-9]+}} (bytes)
+ELF64:   0x0000000000000000 NULL                 0x0
+ELF64: ]
+
 
 ELF:      NeededLibraries [
 ELF-NEXT:  libc.so.6
index 9931163440347b777fcd924ec3a3cadcd5532c9d..b39d56667c134ad818ffa671f8cc21cd994acc9d 100644 (file)
@@ -1474,12 +1474,11 @@ void ELFDumper<ELFT>::printDynamicTable() {
      << "                 " << "Name/Value\n";
   while (I != E) {
     const Elf_Dyn &Entry = *I;
+    uintX_t Tag = Entry.getTag();
     ++I;
-    W.startLine()
-       << "  "
-       << format(Is64 ? "0x%016" PRIX64 : "0x%08" PRIX64, Entry.getTag())
-       << " " << format("%-21s", getTypeString(Entry.getTag()));
-    printValue(Entry.getTag(), Entry.getVal());
+    W.startLine() << "  " << format_hex(Tag, Is64 ? 18 : 10, true) << " "
+                  << format("%-21s", getTypeString(Tag));
+    printValue(Tag, Entry.getVal());
     OS << "\n";
   }