NAME=pd inv fcnsign
FILE=bins/mach0/mac-ls3
ARGS=-a x86 -b 64
CMDS=<<EOF
e asm.cmt.col=0
e asm.addr=false
e asm.bytes=false
e asm.lines=0
e emu.str=true
s..5343
pd 30~(
EOF
EXPECT=<<EOF
 ; int listxattr(0, 0, 0, 0)
 ; void *reallocf(-1, 0)
     call sym.imp.getxattr ; sym.imp.getxattr(-1, -1, 0x0, 0x0)
 ; size_t strlen(-1)
EOF
RUN

NAME=pd movabs string
FILE=-
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 48b9746869735f633030
pd 1
wx 48ba306c5f666c34670a
pd 1
EOF
EXPECT=<<EOF
            0x00000000      48b9746869..   movabs rcx, 0x3030635f73696874 ; 'this_c00'
            0x00000000      48ba306c5f..   movabs rdx, 0xa67346c665f6c30 ; '0l_fl4g\n'
EOF
RUN

NAME=emustr on calls
FILE=bins/mach0/ls-m1
ARGS=-a arm -b64
CMDS=<<EOF
e emu.str=true
?e ---- test strings in calls
s 0x100003b00
pd 1
?e ---- test strings in stores
s 0x100003b58
pd 2
EOF
EXPECT=<<EOF
---- test strings in calls
            0x100003b00      940e0094       bl sym.imp.compat_mode
                                                                       ; bool compat_mode(0, 0)
---- test strings in stores
            0x100003b58      560000b0       adrp x22, segment.__DATA   ; 0x10000c000
            0x100003b5c      c80200b9       str w8, [x22]              ; U"P.\uc004\x01" segment.__DATA
EOF
RUN

NAME=relocs and overlay
FILE=bins/mach0/TrollStore.fat/TrollStore.arm_64.1
ARGS=-e emu.str=true -e bin.relocs.apply=true
CMDS=<<EOF
pd 10 @ 0x100016c40
pv8 1 @ 0x1000261e8
ir~61e8
EOF
EXPECT=<<EOF
            0x100016c40      81000090       adrp x1, reloc.fixup.dequeueReusableCellWithIdentifi ; 0x100026000
            0x100016c44      217c40f9       ldr x1, [x1, 0xf8]         ; (pstr 0x10001bf52) "firstObject" reloc.fixup.firstObject ; str.firstObject
            0x100016c48      510000d0       adrp x17, reloc.CFDictionaryGetTypeID ; 0x100020000
            0x100016c4c      31020791       add x17, x17, 0x1c0        ; reloc.objc_msgSend
            0x100016c50      300240f9       ldr x16, [x17]             ; reloc.objc_msgSend
            0x100016c54      110a1fd7       braa x16, x17
            0x100016c58      200020d4       brk 1
            0x100016c5c      200020d4       brk 1
            0x100016c60      81000090       adrp x1, reloc.fixup.dequeueReusableCellWithIdentifi ; 0x100026000
            0x100016c64      218040f9       ldr x1, [x1, 0x100]        ; (pstr 0x10001bc6c) "generalPasteboard" reloc.fixup.generalPasteboard ; str.generalPasteboard
0x000000010001c6e8
0x1000261e8 0x10001c6e8 SET_64 0      0x10001c6e8
EOF
RUN

NAME=relocs without cache
FILE=bins/mach0/TrollStore.fat/TrollStore.arm_64.1
ARGS=-e emu.str=true -e bin.relocs.apply=false
CMDS=<<EOF
pd 10 @ 0x100016c40
pv8 1 @ 0x1000261e8
uw~1000261e8
ir~61e8
EOF
EXPECT=<<EOF
            0x100016c40      81000090       adrp x1, reloc.fixup.dequeueReusableCellWithIdentifi ; 0x100026000
            0x100016c44      217c40f9       ldr x1, [x1, 0xf8]         ; reloc.fixup.firstObject
            0x100016c48      510000d0       adrp x17, reloc.CFDictionaryGetTypeID ; 0x100020000
            0x100016c4c      31020791       add x17, x17, 0x1c0        ; "8" reloc.objc_msgSend
            0x100016c50      300240f9       ldr x16, [x17]             ; "8" reloc.objc_msgSend
            0x100016c54      110a1fd7       braa x16, x17
            0x100016c58      200020d4       brk 1
            0x100016c5c      200020d4       brk 1
            0x100016c60      81000090       adrp x1, reloc.fixup.dequeueReusableCellWithIdentifi ; 0x100026000
            0x100016c64      218040f9       ldr x1, [x1, 0x100]        ; reloc.fixup.generalPasteboard
0x000800010001c6e8
0x1000261e8 0x10001c6e8 SET_64 0      0x10001c6e8
EOF
RUN
