mirror of
https://github.com/elliotnunn/tbxi.git
synced 2024-06-14 02:29:33 +00:00
Fix sanity-checking of complex ROMs
This commit is contained in:
parent
7a3ece33d8
commit
f5f2ce1dea
|
@ -106,14 +106,14 @@ def parse_configinfo(src_path):
|
||||||
|
|
||||||
|
|
||||||
def insert_and_assert(binary, insertee, offset):
|
def insert_and_assert(binary, insertee, offset):
|
||||||
print(hex(offset))
|
|
||||||
new_len = offset + len(insertee)
|
new_len = offset + len(insertee)
|
||||||
binary.extend(b'\0' * (new_len - len(binary)))
|
binary.extend(b'\0' * (new_len - len(binary)))
|
||||||
|
|
||||||
existing = binary[offset:offset+len(insertee)]
|
existing = binary[offset:offset+len(insertee)]
|
||||||
if existing != insertee and any(existing):
|
if any(existing): # premature optimisation
|
||||||
open('/tmp/elmo', 'wb').write(existing)
|
for a, b in zip(insertee, existing):
|
||||||
raise ValueError('inserting over something else @%X' % offset)
|
if a != 0 and b != 0 and a != b:
|
||||||
|
raise ValueError('inserting over something else @%X' % offset)
|
||||||
|
|
||||||
binary[offset:offset+len(insertee)] = insertee
|
binary[offset:offset+len(insertee)] = insertee
|
||||||
|
|
||||||
|
@ -170,7 +170,10 @@ def build(src):
|
||||||
# The parallel filenames dict tells us what data to put at that address
|
# The parallel filenames dict tells us what data to put at that address
|
||||||
if k in filenames:
|
if k in filenames:
|
||||||
blob = dispatcher.build(path.join(src, filenames[k]))
|
blob = dispatcher.build(path.join(src, filenames[k]))
|
||||||
insert_and_assert(rom, blob, v - fields['ROMImageBaseOffset'])
|
try:
|
||||||
|
insert_and_assert(rom, blob, v - fields['ROMImageBaseOffset'])
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError('Could not insert %r at %s' % (filenames[k], v - fields['ROMImageBaseOffset']))
|
||||||
|
|
||||||
elif header == 'LowMemory':
|
elif header == 'LowMemory':
|
||||||
for words in lines:
|
for words in lines:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user