Add test for bin.cache on macho relocs

This commit is contained in:
pancake 2023-03-14 10:36:58 +01:00
parent 5ce18c6b72
commit 1de7776d2f
2 changed files with 51 additions and 2 deletions

View File

@ -55,3 +55,52 @@ EXPECT=<<EOF
0x100003b5c c80200b9 str w8, [x22] ; U"P.\uc004\x01" segment.__DATA
EOF
RUN
NAME=relocs and cache
FILE=bins/mach0/TrollStore.fat/TrollStore.arm_64.1
ARGS=-e emu.str=true -e bin.cache=true
CMDS=<<EOF
pd 10 @ 0x100016c40
pv8 1 @ 0x1000261e8
uw~1000261e8
ir~61e8
EOF
EXPECT=<<EOF
0x100016c40 81000090 adrp x1, 0x100026000
0x100016c44 217c40f9 ldr x1, [x1, 0xf8] ; 0xdb ; 219 ; str.firstObject
0x100016c48 510000d0 adrp x17, reloc.CFDictionaryGetTypeID ; 0x100020000
0x100016c4c 31020791 add x17, x17, 0x1c0 ; reloc.objc_msgSend
0x100016c50 300240f9 ldr x16, [x17] ; 0xeb ; 235 ; reloc.objc_msgSend
0x100016c54 110a1fd7 braa x16, x17
0x100016c58 200020d4 brk 1
0x100016c5c 200020d4 brk 1
0x100016c60 81000090 adrp x1, 0x100026000
0x100016c64 218040f9 ldr x1, [x1, 0x100] ; 0xdb ; 219 ; str.generalPasteboard
0x000000010001c6e8
idx=1809 addr=0x1000261e8 size=8 e8c6010001000800 -> e8c6010001000000 (not written)
EOF
RUN
NAME=relocs without cache
FILE=bins/mach0/TrollStore.fat/TrollStore.arm_64.1
ARGS=-e emu.str=true -e bin.cache=false
CMDS=<<EOF
pd 10 @ 0x100016c40
pv8 1 @ 0x1000261e8
uw~1000261e8
ir~61e8
EOF
EXPECT=<<EOF
0x100016c40 81000090 adrp x1, 0x100026000
0x100016c44 217c40f9 ldr x1, [x1, 0xf8] ; 0xdb ; 219
0x100016c48 510000d0 adrp x17, reloc.CFDictionaryGetTypeID ; 0x100020000
0x100016c4c 31020791 add x17, x17, 0x1c0 ; "8" reloc.objc_msgSend
0x100016c50 300240f9 ldr x16, [x17] ; 0xeb ; 235 ; reloc.objc_msgSend
0x100016c54 110a1fd7 braa x16, x17
0x100016c58 200020d4 brk 1
0x100016c5c 200020d4 brk 1
0x100016c60 81000090 adrp x1, 0x100026000
0x100016c64 218040f9 ldr x1, [x1, 0x100] ; 0xdb ; 219
0x000800010001c6e8
EOF
RUN

View File

@ -26,7 +26,7 @@ EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
WARN: run r2 with -e bin.cache=true to fix relocations in disassembly
ERROR: [cmd_write.c:184] Cannot write. Check `omp` or reopen the file with `oo+`
ERROR: [cmd_write.c:184] Cannot write. Use `omf`, `io.cache` or reopen the file in rw with `oo+`
EOF
RUN
@ -46,6 +46,6 @@ hello
EOF
EXPECT_ERR=<<EOF
WARN: run r2 with -e bin.cache=true to fix relocations in disassembly
ERROR: [cmd_write_fail] Cannot write. Check `omp` or reopen the file with `oo+`
ERROR: [cmd_write_fail] Cannot write. Use `omf`, `io.cache` or reopen the file in rw with `oo+`
EOF
RUN