mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-31 12:05:05 +02:00
26 lines
724 B
Python
26 lines
724 B
Python
#!/usr/bin/env python3
|
|
"""Find 32-bit bit-address constants referring to a ROM string target."""
|
|
import struct, sys
|
|
|
|
ROM_BASE = 0x07E40000
|
|
|
|
def refs(image, target_off):
|
|
val = (ROM_BASE + target_off) << 3
|
|
pat = struct.pack("<I", val)
|
|
out = []
|
|
start = 0
|
|
while True:
|
|
i = image.find(pat, start)
|
|
if i < 0: break
|
|
out.append(i)
|
|
start = i + 1
|
|
return out, val
|
|
|
|
if __name__ == "__main__":
|
|
image = open(sys.argv[1], "rb").read()
|
|
for arg in sys.argv[2:]:
|
|
off = int(arg, 0)
|
|
r, v = refs(image, off)
|
|
s = image[off:off+60].split(b"\0")[0].decode("latin1", "replace")
|
|
print(f"target 0x{off:06X} val=0x{v:08X} refs={[hex(x) for x in r]} {s!r}")
|