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
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):
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):
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):
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 "])"