2017-05-30 15:48:19 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
|
2017-06-13 14:50:03 +00:00
|
|
|
|
2017-05-30 15:48:19 +00:00
|
|
|
def pairwise(iterable):
|
|
|
|
a = iter(iterable)
|
|
|
|
return zip(a, a)
|
|
|
|
|
2017-09-05 21:15:47 +00:00
|
|
|
|
2017-05-30 15:48:19 +00:00
|
|
|
files = sys.argv[1:]
|
|
|
|
files = list(pairwise(files))
|
|
|
|
|
|
|
|
offset = int(files[0][0], 16)
|
|
|
|
|
|
|
|
out = bytearray()
|
|
|
|
|
|
|
|
for addr, fn in files:
|
|
|
|
addr = int(addr, 16) - offset
|
2018-07-31 09:35:09 +00:00
|
|
|
data = open(fn, "rb").read()
|
2017-05-30 15:48:19 +00:00
|
|
|
if len(out) < addr:
|
2018-07-31 09:35:09 +00:00
|
|
|
out += b"\x00" * (addr - len(out))
|
2017-05-30 15:48:19 +00:00
|
|
|
if len(out) != addr:
|
2018-07-31 09:35:09 +00:00
|
|
|
raise Exception("Alignment failed")
|
2017-05-30 15:48:19 +00:00
|
|
|
out += data
|
|
|
|
|
|
|
|
sys.stdout.buffer.write(out)
|