1
0
mirror of https://github.com/weiju/amiga-stuff synced 2025-11-23 19:01:45 +00:00

grouping the hunk blocks with their relocation information

This commit is contained in:
Wei-ju Wu
2014-12-04 07:54:54 -08:00
parent d3d110945c
commit 2bcaf5188a

View File

@ -144,31 +144,51 @@ def parse_hunkfile(hunkfile):
print("hunk sizes: ", hunk_sizes)
elif id == HUNK_BLOCK_UNIT:
strlen = read_int32(infile) * 4
print("# name: %d" % strlen)
#print("# name: %d" % strlen)
unit_name = str(infile.read(strlen))
print("UNIT '%s'" % unit_name)
print("---------------------------------------------")
else:
is_loadfile = False
raise Exception('Unsupported header type')
blocks = read_blocks(infile, is_loadfile)
print("%d blocks read: " % len(blocks))
#print("%d blocks read: " % len(blocks))
# group the blocks into relocation groups
groups = []
for block in blocks:
if block[0] in {'NAME', 'UNIT'}:
continue
elif block[0] in {'BSS', 'CODE', 'DATA'}:
current_group = []
if block[0] == 'END':
groups.append(current_group)
current_group = []
else:
current_group.append(block)
for i, group in enumerate(groups):
names = ','.join([block[0] for block in group])
print("Group %d -> %s" % (i, names))
"""
for i, block in enumerate(blocks):
if block[0] == 'NAME':
print("Block %d: '%s' -> '%s'" % (i, block[0], block[1]))
print("%d: '%s' -> '%s'" % (i, block[0], block[1]))
elif block[0] == 'BSS':
print("Block %d: '%s' -> %d" % (i, block[0], block[1]))
print("%d: '%s' -> %d" % (i, block[0], block[1]))
elif block[0] == 'CODE':
print("%d: '%s', size = %d" % (i, block[0], len(block[1])))
print("----------------------------\n")
code = block[1]
disassemble(code)
print("\n---------------------------\n")
#print("----------------------------\n")
#code = block[1]
#disassemble(code)
#print("\n---------------------------\n")
elif block[0] == 'RELOC32':
print("%d: '%s': %s" % (i, block[0], block[1]))
else:
print("Block %d: '%s'" % (i, block[0]))
print("%d: '%s'" % (i, block[0]))"""
if __name__ == '__main__':