X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FScripts%2Felf-dump;h=784533c57bd6f7cab11cd57f44b85545b2369ffe;hb=4845f990081d466ad193d90d1cd6f1d0eb910309;hp=f6ec186e50ddf2bb2fbef80d4c75ab551bbdbae1;hpb=4a23a376c03692dd12421e49f8e34be0e26f101e;p=oota-llvm.git diff --git a/test/Scripts/elf-dump b/test/Scripts/elf-dump index f6ec186e50d..784533c57bd 100755 --- a/test/Scripts/elf-dump +++ b/test/Scripts/elf-dump @@ -77,16 +77,16 @@ class Section: self.sh_entsize = f.readWord() def dump(self, shstrtab, f, strtab, dumpdata): - 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) + print " (('sh_name', %s)" % common_dump.HexDump(self.sh_name), "# %r" % shstrtab[self.sh_name] + print " ('sh_type', %s)" % common_dump.HexDump(self.sh_type) + print " ('sh_flags', %s)" % common_dump.HexDump(self.sh_flags) + print " ('sh_addr', %s)" % common_dump.HexDump(self.sh_addr) + print " ('sh_offset', %s)" % common_dump.HexDump(self.sh_offset) + print " ('sh_size', %s)" % common_dump.HexDump(self.sh_size) + print " ('sh_link', %s)" % common_dump.HexDump(self.sh_link) + print " ('sh_info', %s)" % common_dump.HexDump(self.sh_info) + print " ('sh_addralign', %s)" % common_dump.HexDump(self.sh_addralign) + print " ('sh_entsize', %s)" % common_dump.HexDump(self.sh_entsize) if self.sh_type == 2: # SHT_SYMTAB print " ('_symbols', [" dumpSymtab(f, self, strtab) @@ -106,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" % hex(index) + print " # Symbol %s" % common_dump.HexDump(index) name = f.read32() - print " (('st_name', %s)" % hex(name), "# %r" % strtab[name] + print " (('st_name', %s)" % common_dump.HexDump(name), "# %r" % strtab[name] if not f.is64Bit: - print " ('st_value', %s)" % hex(f.read32()) - print " ('st_size', %s)" % hex(f.read32()) + print " ('st_value', %s)" % common_dump.HexDump(f.read32()) + print " ('st_size', %s)" % common_dump.HexDump(f.read32()) st_info = f.read8() - 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()) + print " ('st_bind', %s)" % common_dump.HexDump((st_info >> 4)) + print " ('st_type', %s)" % common_dump.HexDump((st_info & 0xf)) + 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)" % hex(f.read64()) - print " ('st_size', %s)" % hex(f.read64()) + print " ('st_value', %s)" % common_dump.HexDump(f.read64()) + print " ('st_size', %s)" % common_dump.HexDump(f.read64()) print " )," def dumpRel(f, section, dumprela = False): @@ -127,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" % hex(index) - print " (('r_offset', %s)" % hex(f.readWord()) + print " # Relocation %s" % common_dump.HexDump(index) + print " (('r_offset', %s)" % common_dump.HexDump(f.readWord()) r_info = f.readWord() if f.is64Bit: - print " ('r_sym', %s)" % hex((r_info >> 32)) - print " ('r_type', %s)" % hex((r_info & 0xffffffff)) + print " ('r_sym', %s)" % common_dump.HexDump((r_info >> 32)) + print " ('r_type', %s)" % common_dump.HexDump((r_info & 0xffffffff)) else: - print " ('r_sym', %s)" % hex((r_info >> 8)) - print " ('r_type', %s)" % hex((r_info & 0xff)) + 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)" % hex(f.readWordS()) + print " ('r_addend', %s)" % common_dump.HexDump(f.readWordS()) print " )," def dumpELF(path, opts): @@ -152,8 +152,8 @@ def dumpELF(path, opts): elif fileclass == 2: # ELFCLASS64 f.is64Bit = True else: - raise ValueError, "Unknown file class %s" % hex(fileclass) - print "('e_indent[EI_CLASS]', %s)" % hex(fileclass) + raise ValueError, "Unknown file class %s" % common_dump.HexDump(fileclass) + print "('e_indent[EI_CLASS]', %s)" % common_dump.HexDump(fileclass) byteordering = f.read8() if byteordering == 1: # ELFDATA2LSB @@ -161,32 +161,32 @@ def dumpELF(path, opts): elif byteordering == 2: # ELFDATA2MSB f.isLSB = False else: - raise ValueError, "Unknown byte ordering %s" % hex(byteordering) - print "('e_indent[EI_DATA]', %s)" % hex(byteordering) + raise ValueError, "Unknown byte ordering %s" % common_dump.HexDump(byteordering) + print "('e_indent[EI_DATA]', %s)" % common_dump.HexDump(byteordering) - 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()) + print "('e_indent[EI_VERSION]', %s)" % common_dump.HexDump(f.read8()) + print "('e_indent[EI_OSABI]', %s)" % common_dump.HexDump(f.read8()) + print "('e_indent[EI_ABIVERSION]', %s)" % common_dump.HexDump(f.read8()) f.seek(16) # Seek to end of e_ident. - 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()) + print "('e_type', %s)" % common_dump.HexDump(f.read16()) + print "('e_machine', %s)" % common_dump.HexDump(f.read16()) + print "('e_version', %s)" % common_dump.HexDump(f.read32()) + print "('e_entry', %s)" % common_dump.HexDump(f.readWord()) + print "('e_phoff', %s)" % common_dump.HexDump(f.readWord()) e_shoff = f.readWord() - 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()) + print "('e_shoff', %s)" % common_dump.HexDump(e_shoff) + print "('e_flags', %s)" % common_dump.HexDump(f.read32()) + print "('e_ehsize', %s)" % common_dump.HexDump(f.read16()) + print "('e_phentsize', %s)" % common_dump.HexDump(f.read16()) + print "('e_phnum', %s)" % common_dump.HexDump(f.read16()) e_shentsize = f.read16() - print "('e_shentsize', %s)" % hex(e_shentsize) + print "('e_shentsize', %s)" % common_dump.HexDump(e_shentsize) e_shnum = f.read16() - print "('e_shnum', %s)" % hex(e_shnum) + print "('e_shnum', %s)" % common_dump.HexDump(e_shnum) e_shstrndx = f.read16() - print "('e_shstrndx', %s)" % hex(e_shstrndx) + print "('e_shstrndx', %s)" % common_dump.HexDump(e_shstrndx) # Read all section headers sections = [] @@ -209,7 +209,7 @@ def dumpELF(path, opts): print "('_sections', [" for index in range(e_shnum): - print " # Section %s" % hex(index) + print " # Section %s" % common_dump.HexDump(index) sections[index].dump(shstrtab, f, strtab, opts.dumpSectionData) print "])"