Implement bisection

This commit is contained in:
Takumi Sueda 2021-03-06 00:02:19 +09:00
parent 7372479efc
commit cef69aef53
4 changed files with 29 additions and 10 deletions

View File

@ -24,5 +24,7 @@ spray/main.bin:
@./extract.py -p a.out spray/top.bin
@$(AS) spray/bottom.S
@./extract.py -p a.out spray/bottom.bin
@./append_nop.py 15728640 spray/top.bin spray/bottom.bin spray/main.bin
@$(AS) spray/bottom_reset.S
@./extract.py -p a.out spray/bottom_reset.bin
@./append_nop.py spray/top.bin spray/bottom.bin spray/bottom_reset.bin spray/main.bin 112 113
@rm -f a.out

View File

@ -5,20 +5,31 @@ import sys
def main():
if len(sys.argv) < 5:
print(f'Usage: {sys.argv[0]} N top.bin bottom.bin out.bin', file=sys.stderr)
print(f'Usage: {sys.argv[0]} top.bin bottom_loop.bin bottom_reset.bin out.bin reset_fill_from reset_fill_to', file=sys.stderr)
sys.exit(1)
with open(sys.argv[2], 'rb') as topf, open(sys.argv[3], 'rb') as bottomf, open(sys.argv[4], 'wb') as out:
top, bottom = topf.read(), bottomf.read()
with open(sys.argv[1], 'rb') as tf, open(sys.argv[2], 'rb') as btmlf, open(sys.argv[3], 'rb') as btmrf, open(sys.argv[4], 'wb') as out:
top, btml, btmr = tf.read(), btmlf.read(), btmrf.read()
fill_from, fill_to = int(sys.argv[5]), int(sys.argv[6])
out.write(top)
for i in range((1024 * 64 - len(top) - len(bottom)) // 4):
if fill_from == 0:
blen, b = len(btmr), btmr
else:
blen, b = len(btml), btml
for i in range((1024 * 64 - len(top) - blen) // 4):
out.write(b'\x00\x00\xa0\xe1')
out.write(bottom)
out.write(b)
for i in range(1024 * 1024 * 15 // (1024 * 64) - 1):
for i in range((1024 * 64 - len(bottom)) // 4):
if fill_from <= i+1 < fill_to:
blen, b = len(btmr), btmr
else:
blen, b = len(btml), btml
for j in range((1024 * 64 - blen) // 4):
out.write(b'\x00\x00\xa0\xe1')
out.write(bottom)
out.write(b)
main()

View File

@ -4,6 +4,5 @@
_start:
loop:
nop
b loop
ldr r0, =0x00000000
mov pc, r0

7
x1/spray/bottom_reset.S Normal file
View File

@ -0,0 +1,7 @@
.text
.align 2
.global _start
_start:
ldr r0, =0x00000000
mov pc, r0