mirror of
https://frontier.innolan.net/github/amigaos-cross-toolchain6.git
synced 2024-10-19 10:29:55 +00:00
Fix some bugs.
This commit is contained in:
@ -40,24 +40,34 @@ if __name__ == '__main__':
|
||||
s = e + 1
|
||||
|
||||
print header
|
||||
print ''
|
||||
|
||||
print "Text:"
|
||||
util.hexdump(text_seg)
|
||||
if text_seg:
|
||||
print 'Text:'
|
||||
util.hexdump(text_seg)
|
||||
print ''
|
||||
|
||||
print "Data:"
|
||||
util.hexdump(data_seg)
|
||||
if data_seg:
|
||||
print 'Data:'
|
||||
util.hexdump(data_seg)
|
||||
print ''
|
||||
|
||||
print "Symbols:"
|
||||
print 'Symbols:'
|
||||
for i in range(0, len(symbols), 12):
|
||||
symbol = aout.SymbolInfo.decode(symbols[i:i + 12])
|
||||
print ' ', symbol.as_string(str_map)
|
||||
print ''
|
||||
|
||||
print "Text relocations:"
|
||||
for i in range(0, len(text_reloc), 8):
|
||||
reloc = aout.RelocInfo.decode(text_reloc[i:i + 8])
|
||||
print ' ', reloc.as_string(str_table)
|
||||
if text_reloc:
|
||||
print 'Text relocations:'
|
||||
for i in range(0, len(text_reloc), 8):
|
||||
reloc = aout.RelocInfo.decode(text_reloc[i:i + 8])
|
||||
print ' ', reloc.as_string(str_table)
|
||||
print ''
|
||||
|
||||
print "Data relocations:"
|
||||
for i in range(0, len(data_reloc), 8):
|
||||
reloc = aout.RelocInfo.decode(data_reloc[i:i + 8])
|
||||
print ' ', reloc.as_string(str_table)
|
||||
if data_reloc:
|
||||
print 'Data relocations:'
|
||||
for i in range(0, len(data_reloc), 8):
|
||||
reloc = aout.RelocInfo.decode(data_reloc[i:i + 8])
|
||||
print ' ', reloc.as_string(str_table)
|
||||
print ''
|
||||
|
||||
@ -23,6 +23,9 @@ class Header(namedtuple('Header', ('mid', 'magic', 'text', 'data', 'bss',
|
||||
mid = name
|
||||
break
|
||||
|
||||
if magic not in cls.magic_map or mid not in cls.mid_map:
|
||||
raise ValueError('Not a valid a.out header!')
|
||||
|
||||
return cls(mid, magic, text, data, bss, syms, entry, trsize, drsize)
|
||||
|
||||
|
||||
@ -46,7 +49,17 @@ class RelocInfo(namedtuple('RelocInfo', ('address', 'symbolnum', 'pcrel',
|
||||
|
||||
def as_string(self, str_table):
|
||||
t = '{0}{1}'.format('BASE' if self.baserel else '', 8 * (1 << self.length))
|
||||
s = str_table[self.symbolnum]
|
||||
try:
|
||||
s = str_table[self.symbolnum]
|
||||
except IndexError:
|
||||
if self.symbolnum == 4:
|
||||
s = '.text'
|
||||
elif self.symbolnum == 6:
|
||||
s = '.data'
|
||||
elif self.symbolnum == 8:
|
||||
s = '.bss'
|
||||
else:
|
||||
s = str(self.symbolnum)
|
||||
return '{0:08x} {1:>6} {2}'.format(self.address, t, s)
|
||||
|
||||
|
||||
@ -55,8 +68,12 @@ class SymbolInfo(namedtuple('SymbolInfo', ('strx', 'type', 'other', 'desc',
|
||||
type_map = [
|
||||
('UNDF', 0x00), ('EXT', 0x01), ('ABS', 0x02), ('TEXT', 0x04),
|
||||
('DATA', 0x06), ('BSS', 0x08), ('INDR', 0x0a), ('SIZE', 0x0c),
|
||||
('COMM', 0x12), ('FN', 0x1e), ('WARN', 0x1e), ('TYPE', 0x1e),
|
||||
('SLINE', 0x44), ('SO', 0x64), ('SOL', 0x84), ('STAB', 0xe0)]
|
||||
('COMM', 0x12), ('FN', 0x1e), ('WARN', 0x1e), ('TYPE', 0x1e), ('FN', 0x1f),
|
||||
('GSYM', 0x20), ('FNAME', 0x22), ('FUN', 0x24), ('STSYM', 0x26),
|
||||
('LCSYM', 0x28), ('RSYM', 0x40), ('SLINE', 0x44), ('SSYM', 0x60),
|
||||
('SO', 0x64), ('LSYM', 0x80), ('SOL', 0x84), ('PSYM', 0xa0),
|
||||
('ENTRY', 0xa4), ('LBRAC', 0xc0), ('STAB', 0xe0), ('RBRAC', 0xe0),
|
||||
('BCOMM', 0xe2), ('ECOMM', 0xe4), ('ECOML', 0xe8), ('LENG', 0xfe)]
|
||||
|
||||
@classmethod
|
||||
def decode(cls, data):
|
||||
@ -74,9 +91,11 @@ class SymbolInfo(namedtuple('SymbolInfo', ('strx', 'type', 'other', 'desc',
|
||||
for t, v in self.type_map:
|
||||
if (self.type & ~1) == v:
|
||||
return t
|
||||
return 'DEBUG'
|
||||
|
||||
def as_string(self, str_map):
|
||||
visibility = 'g' if self.external else 'l'
|
||||
return '{3:08x} {5} {0:>4} {2:04x} {1:02x} {6:02x} {4}'.format(
|
||||
self.type_str, self.other, self.desc, self.value, str_map[self.strx],
|
||||
symbol = str_map.get(self.strx, '')
|
||||
return '{3:08x} {5} {0:<5} {2:04x} {1:02x} {6:02x} {4}'.format(
|
||||
self.type_str, self.other, self.desc, self.value, symbol,
|
||||
visibility, self.type)
|
||||
|
||||
Reference in New Issue
Block a user