mirror of
https://github.com/brain-hackers/lab
synced 2025-01-22 11:20:05 +09:00
Implement bisection
This commit is contained in:
parent
7372479efc
commit
cef69aef53
@ -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
|
||||
|
@ -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()
|
||||
|
@ -4,6 +4,5 @@
|
||||
|
||||
_start:
|
||||
loop:
|
||||
nop
|
||||
b loop
|
||||
ldr r0, =0x00000000
|
||||
mov pc, r0
|
||||
|
7
x1/spray/bottom_reset.S
Normal file
7
x1/spray/bottom_reset.S
Normal file
@ -0,0 +1,7 @@
|
||||
.text
|
||||
.align 2
|
||||
.global _start
|
||||
|
||||
_start:
|
||||
ldr r0, =0x00000000
|
||||
mov pc, r0
|
Loading…
Reference in New Issue
Block a user