NAME=1: thumb entry0
FILE=bins/elf/arm-init
CMDS=ie
EXPECT=<<EOF
[Entrypoints]
vaddr=0x000002e4 paddr=0x000002e4 haddr=0x00000018 hvaddr=0x00000018 type=program

1 entrypoints
EOF
RUN

NAME=2: thumb entry0
FILE=bins/elf/arm-init
CMDS=iee
EXPECT=<<EOF
[Constructors]
vaddr=0x000002e4 paddr=0x000002e4 hvaddr=0x00001ed0 hpaddr=0x00000ed0 type=fini
vaddr=0x00000344 paddr=0x00000344 hvaddr=0x00001ed8 hpaddr=0x00000ed8 type=init

2 entrypoints
EOF
RUN

NAME=3: thumb entry0
FILE=bins/elf/analysis/thumb
CMDS=?v entry0
EXPECT=<<EOF
0x82f0
EOF
RUN

NAME=thumb main
FILE=bins/elf/analysis/thumb
CMDS=?v sym.main
EXPECT=<<EOF
0x8424
EOF
RUN

NAME=thumb main alignment
FILE=bins/elf/analysis/thumb
CMDS=<<EOF
s sym.main
pi 1
EOF
EXPECT=<<EOF
push {r7, lr}
EOF
RUN

NAME=thumb sym
FILE=bins/elf/analysis/thumb
BROKEN=1
CMDS=is~main
EXPECT=<<EOF
107 0x00000424 0x00008424 GLOBAL   FUNC   16 main
001 0x000002bc 0x000082bc GLOBAL   FUNC   16 imp.__libc_start_main
EOF
RUN

NAME=thumb disasm
FILE=bins/elf/analysis/thumb
CMDS=pi 1@ sym.main
EXPECT=<<EOF
push {r7, lr}
EOF
RUN

NAME=thumb disasm 2
FILE=bins/elf/analysis/thumb
CMDS=pi 7@ sym.main
EXPECT=<<EOF
push {r7, lr}
add r7, sp, 0
movs r0, 0xa
bl 0x82d4
adds r0, r3, 0
mov sp, r7
pop {r7, pc}
EOF
RUN

NAME=mix arm and thumb
FILE=bins/elf/analysis/thumb
CMDS=pi 14@ sym.main
EXPECT=<<EOF
push {r7, lr}
add r7, sp, 0
movs r0, 0xa
bl 0x82d4
adds r0, r3, 0
mov sp, r7
pop {r7, pc}
push {r3, r4, r5, r6, r7, r8, sl, lr}
mov r5, r0
mov r6, r1
mov r7, r2
ldr r8, [0x00008494]
bl sym._init
ldr r3, [0x00008498]
EOF
RUN

NAME=arm disasm entry0
FILE=bins/elf/analysis/thumb
CMDS=pi 1@ sym.main
EXPECT=<<EOF
push {r7, lr}
EOF
RUN

NAME=thumb analysis expand
FILE=bins/elf/analysis/thumb
CMDS=<<EOF
pi 2@sym.main
af@sym.main
pi 2 @sym.main
EOF
EXPECT=<<EOF
push {r7, lr}
add r7, sp, 0
push {r7, lr}
add r7, var_0h
EOF
RUN

NAME=arm at entry libsimplejni.so
FILE=bins/elf/analysis/libsimplejni.so
CMDS=pi 7@entry0
EXPECT=<<EOF
push {fp, lr}
add fp, sp, 4
ldr r3, [0x00000f64]
add r3, pc, r3
mov r0, r3
bl sym.imp.__cxa_finalize
pop {fp, pc}
EOF
RUN

NAME=thumb at sym.JNI_OnLoad
FILE=bins/elf/analysis/libsimplejni.so
CMDS=pi 6@sym.JNI_OnLoad
EXPECT=<<EOF
push {r4, lr}
sub sp, 8
mov r4, r0
ldr r0, [0x000010e0]
ldr r1, [0x000010e4]
add r0, pc
EOF
RUN
