Get rid of unneeded FormatOutput global variable

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116756 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jason W Kim 2010-10-18 21:59:38 +00:00
parent d49e2aa5b8
commit 4a23a376c0

View File

@ -6,8 +6,6 @@ import StringIO
import common_dump
FormatOutput=hex
class Reader:
def __init__(self, path):
if path == "-":
@ -79,16 +77,16 @@ class Section:
self.sh_entsize = f.readWord()
def dump(self, shstrtab, f, strtab, dumpdata):
print " (('sh_name', %s)" % FormatOutput(self.sh_name), "# %r" % shstrtab[self.sh_name]
print " ('sh_type', %s)" % FormatOutput(self.sh_type)
print " ('sh_flags', %s)" % FormatOutput(self.sh_flags)
print " ('sh_addr', %s)" % FormatOutput(self.sh_addr)
print " ('sh_offset', %s)" % FormatOutput(self.sh_offset)
print " ('sh_size', %s)" % FormatOutput(self.sh_size)
print " ('sh_link', %s)" % FormatOutput(self.sh_link)
print " ('sh_info', %s)" % FormatOutput(self.sh_info)
print " ('sh_addralign', %s)" % FormatOutput(self.sh_addralign)
print " ('sh_entsize', %s)" % FormatOutput(self.sh_entsize)
print " (('sh_name', %s)" % hex(self.sh_name), "# %r" % shstrtab[self.sh_name]
print " ('sh_type', %s)" % hex(self.sh_type)
print " ('sh_flags', %s)" % hex(self.sh_flags)
print " ('sh_addr', %s)" % hex(self.sh_addr)
print " ('sh_offset', %s)" % hex(self.sh_offset)
print " ('sh_size', %s)" % hex(self.sh_size)
print " ('sh_link', %s)" % hex(self.sh_link)
print " ('sh_info', %s)" % hex(self.sh_info)
print " ('sh_addralign', %s)" % hex(self.sh_addralign)
print " ('sh_entsize', %s)" % hex(self.sh_entsize)
if self.sh_type == 2: # SHT_SYMTAB
print " ('_symbols', ["
dumpSymtab(f, self, strtab)
@ -108,20 +106,20 @@ def dumpSymtab(f, section, strtab):
for index in range(entries):
f.seek(section.sh_offset + index * section.sh_entsize)
print " # Symbol %s" % FormatOutput(index)
print " # Symbol %s" % hex(index)
name = f.read32()
print " (('st_name', %s)" % FormatOutput(name), "# %r" % strtab[name]
print " (('st_name', %s)" % hex(name), "# %r" % strtab[name]
if not f.is64Bit:
print " ('st_value', %s)" % FormatOutput(f.read32())
print " ('st_size', %s)" % FormatOutput(f.read32())
print " ('st_value', %s)" % hex(f.read32())
print " ('st_size', %s)" % hex(f.read32())
st_info = f.read8()
print " ('st_bind', %s)" % FormatOutput((st_info >> 4))
print " ('st_type', %s)" % FormatOutput((st_info & 0xf))
print " ('st_other', %s)" % FormatOutput(f.read8())
print " ('st_shndx', %s)" % FormatOutput(f.read16())
print " ('st_bind', %s)" % hex((st_info >> 4))
print " ('st_type', %s)" % hex((st_info & 0xf))
print " ('st_other', %s)" % hex(f.read8())
print " ('st_shndx', %s)" % hex(f.read16())
if f.is64Bit:
print " ('st_value', %s)" % FormatOutput(f.read64())
print " ('st_size', %s)" % FormatOutput(f.read64())
print " ('st_value', %s)" % hex(f.read64())
print " ('st_size', %s)" % hex(f.read64())
print " ),"
def dumpRel(f, section, dumprela = False):
@ -129,17 +127,17 @@ def dumpRel(f, section, dumprela = False):
for index in range(entries):
f.seek(section.sh_offset + index * section.sh_entsize)
print " # Relocation %s" % FormatOutput(index)
print " (('r_offset', %s)" % FormatOutput(f.readWord())
print " # Relocation %s" % hex(index)
print " (('r_offset', %s)" % hex(f.readWord())
r_info = f.readWord()
if f.is64Bit:
print " ('r_sym', %s)" % FormatOutput((r_info >> 32))
print " ('r_type', %s)" % FormatOutput((r_info & 0xffffffff))
print " ('r_sym', %s)" % hex((r_info >> 32))
print " ('r_type', %s)" % hex((r_info & 0xffffffff))
else:
print " ('r_sym', %s)" % FormatOutput((r_info >> 8))
print " ('r_type', %s)" % FormatOutput((r_info & 0xff))
print " ('r_sym', %s)" % hex((r_info >> 8))
print " ('r_type', %s)" % hex((r_info & 0xff))
if dumprela:
print " ('r_addend', %s)" % FormatOutput(f.readWordS())
print " ('r_addend', %s)" % hex(f.readWordS())
print " ),"
def dumpELF(path, opts):
@ -154,8 +152,8 @@ def dumpELF(path, opts):
elif fileclass == 2: # ELFCLASS64
f.is64Bit = True
else:
raise ValueError, "Unknown file class %s" % FormatOutput(fileclass)
print "('e_indent[EI_CLASS]', %s)" % FormatOutput(fileclass)
raise ValueError, "Unknown file class %s" % hex(fileclass)
print "('e_indent[EI_CLASS]', %s)" % hex(fileclass)
byteordering = f.read8()
if byteordering == 1: # ELFDATA2LSB
@ -163,32 +161,32 @@ def dumpELF(path, opts):
elif byteordering == 2: # ELFDATA2MSB
f.isLSB = False
else:
raise ValueError, "Unknown byte ordering %s" % FormatOutput(byteordering)
print "('e_indent[EI_DATA]', %s)" % FormatOutput(byteordering)
raise ValueError, "Unknown byte ordering %s" % hex(byteordering)
print "('e_indent[EI_DATA]', %s)" % hex(byteordering)
print "('e_indent[EI_VERSION]', %s)" % FormatOutput(f.read8())
print "('e_indent[EI_OSABI]', %s)" % FormatOutput(f.read8())
print "('e_indent[EI_ABIVERSION]', %s)" % FormatOutput(f.read8())
print "('e_indent[EI_VERSION]', %s)" % hex(f.read8())
print "('e_indent[EI_OSABI]', %s)" % hex(f.read8())
print "('e_indent[EI_ABIVERSION]', %s)" % hex(f.read8())
f.seek(16) # Seek to end of e_ident.
print "('e_type', %s)" % FormatOutput(f.read16())
print "('e_machine', %s)" % FormatOutput(f.read16())
print "('e_version', %s)" % FormatOutput(f.read32())
print "('e_entry', %s)" % FormatOutput(f.readWord())
print "('e_phoff', %s)" % FormatOutput(f.readWord())
print "('e_type', %s)" % hex(f.read16())
print "('e_machine', %s)" % hex(f.read16())
print "('e_version', %s)" % hex(f.read32())
print "('e_entry', %s)" % hex(f.readWord())
print "('e_phoff', %s)" % hex(f.readWord())
e_shoff = f.readWord()
print "('e_shoff', %s)" % FormatOutput(e_shoff)
print "('e_flags', %s)" % FormatOutput(f.read32())
print "('e_ehsize', %s)" % FormatOutput(f.read16())
print "('e_phentsize', %s)" % FormatOutput(f.read16())
print "('e_phnum', %s)" % FormatOutput(f.read16())
print "('e_shoff', %s)" % hex(e_shoff)
print "('e_flags', %s)" % hex(f.read32())
print "('e_ehsize', %s)" % hex(f.read16())
print "('e_phentsize', %s)" % hex(f.read16())
print "('e_phnum', %s)" % hex(f.read16())
e_shentsize = f.read16()
print "('e_shentsize', %s)" % FormatOutput(e_shentsize)
print "('e_shentsize', %s)" % hex(e_shentsize)
e_shnum = f.read16()
print "('e_shnum', %s)" % FormatOutput(e_shnum)
print "('e_shnum', %s)" % hex(e_shnum)
e_shstrndx = f.read16()
print "('e_shstrndx', %s)" % FormatOutput(e_shstrndx)
print "('e_shstrndx', %s)" % hex(e_shstrndx)
# Read all section headers
sections = []
@ -211,7 +209,7 @@ def dumpELF(path, opts):
print "('_sections', ["
for index in range(e_shnum):
print " # Section %s" % FormatOutput(index)
print " # Section %s" % hex(index)
sections[index].dump(shstrtab, f, strtab, opts.dumpSectionData)
print "])"