Don't print a counter in hex.
[oota-llvm.git] / test / Scripts / elf-dump
index 784533c57bd6f7cab11cd57f44b85545b2369ffe..9794bfd9d8dc93b6d667249a400e19677a4c4660 100755 (executable)
@@ -34,27 +34,15 @@ class Reader:
     def read32(self):
         return struct.unpack('><'[self.isLSB] + 'I', self.read(4))[0]
 
-    def read32S(self):
-        return struct.unpack('><'[self.isLSB] + 'i', self.read(4))[0]
-
     def read64(self):
         return struct.unpack('><'[self.isLSB] + 'Q', self.read(8))[0]
 
-    def read64S(self):
-        return struct.unpack('><'[self.isLSB] + 'q', self.read(8))[0]
-
     def readWord(self):
         if self.is64Bit:
             return self.read64()
         else:
             return self.read32()
 
-    def readWordS(self):
-        if self.is64Bit:
-            return self.read64S()
-        else:
-            return self.read32S()
-
 class StringTable:
     def __init__(self, strings):
        self.string_table = strings
@@ -97,8 +85,11 @@ class Section:
             print "   ])"
         elif dumpdata:
             f.seek(self.sh_offset)
-            data = f.read(self.sh_size)
-            print "   ('_section_data', '%s')" % common_dump.dataToHex(data)
+            if self.sh_type != 8: # != SHT_NOBITS
+                data = f.read(self.sh_size)
+                print "   ('_section_data', '%s')" % common_dump.dataToHex(data)
+            else:
+                print "   ('_section_data', '')" 
         print "  ),"
 
 def dumpSymtab(f, section, strtab):
@@ -118,8 +109,8 @@ def dumpSymtab(f, section, strtab):
         print "     ('st_other', %s)" % common_dump.HexDump(f.read8())
         print "     ('st_shndx', %s)" % common_dump.HexDump(f.read16())
         if f.is64Bit:
-            print "     ('st_value', %s)" % common_dump.HexDump(f.read64())
-            print "     ('st_size', %s)" % common_dump.HexDump(f.read64())
+            print "     ('st_value', %s)" % common_dump.HexDump(f.read64(), 64)
+            print "     ('st_size', %s)" % common_dump.HexDump(f.read64(), 64)
         print "    ),"
 
 def dumpRel(f, section, dumprela = False):
@@ -137,7 +128,12 @@ def dumpRel(f, section, dumprela = False):
             print "     ('r_sym', %s)" % common_dump.HexDump((r_info >> 8))
             print "     ('r_type', %s)" % common_dump.HexDump((r_info & 0xff))
         if dumprela:
-            print "     ('r_addend', %s)" % common_dump.HexDump(f.readWordS())
+            val = f.readWord()
+            if f.is64Bit:
+                numBits = 64
+            else:
+                numBits = 32
+            print "     ('r_addend', %s)" % common_dump.HexDump(val, numBits)
         print "    ),"
 
 def dumpELF(path, opts):
@@ -209,7 +205,7 @@ def dumpELF(path, opts):
 
     print "('_sections', ["
     for index in range(e_shnum):
-        print "  # Section %s" % common_dump.HexDump(index)
+        print "  # Section %s" % index
         sections[index].dump(shstrtab, f, strtab, opts.dumpSectionData)
     print "])"