NAME=ELF: arm relocs
FILE=bins/elf/analysis/arm-relocs
CMDS=<<EOF
ir*~reloc?
ir*~!1
EOF
EXPECT=<<EOF
11
fs relocs
'f reloc.r0 4 0x08000034
'f reloc.r2 4 0x0800003c
'f reloc.r3 4 0x08000040
'f reloc.r4 4 0x08000044
'f reloc.r0 4 0x0800004c
'f reloc.r2 4 0x08000054
'f reloc.r3 4 0x08000058
'f reloc.r4 4 0x0800005c
wv8 0xffffffffffffffff @ 0x8000060
EOF
RUN

NAME=ELF: ppc relocs
FILE=bins/elf/hello.ppc
CMDS=<<EOF
ii
ir
s main
af
pdsf
EOF
EXPECT=<<EOF
[Imports]
nth vaddr      bind   type   lib name
-------------------------------------
1   ---------- GLOBAL FUNC       printf
2   ---------- WEAK   NOTYPE     __gmon_start__
3   ---------- GLOBAL FUNC       __libc_start_main

[Relocations]

vaddr      paddr      type   ntype name
---------------------------------------
0x10020008 0x00010008 ADD_32 20    __gmon_start__
0x10020064 0x10020064 ADD_32 21    printf
0x1002006c 0x1002006c ADD_32 21    __gmon_start__
0x10020074 0x10020074 ADD_32 21    __libc_start_main


4 relocations
0x100004a0 str.Simple_PPC_program. str.Simple_PPC_program.
0x100004a4 "Simple PPC program."
EOF
RUN

NAME=ELF: arm sh relocs
ARGS=-e bin.relocs.apply=true
FILE=bins/elf/r2pay-arm32.so
CMDS=<<EOF
ir*~reloc?
s section..init_array
pd 10
EOF
EXPECT=<<EOF
366
            ;-- section..init_array:
            0x000b58c4      .dword 0x00004560 ; reloc..datadiv_decode1794556967687044894 ; sym..datadiv_decode1794556967687044894 ; [15] -rw- section size 364 named .init_array
            0x000b58c8      .dword 0x00004570 ; reloc..datadiv_decode12875440098136793118 ; sym..datadiv_decode12875440098136793118
            0x000b58cc      .dword 0x00098028 ; reloc..datadiv_decode11893604691534341392 ; sym..datadiv_decode11893604691534341392
            0x000b58d0      .dword 0x00008115 ; entry.init0
            0x000b58d4      .dword 0x00055049 ; entry.init1
            0x000b58d8      .dword 0x00098b44 ; reloc..datadiv_decode668687990735969933 ; sym..datadiv_decode668687990735969933
            0x000b58dc      .dword 0x00098b48 ; reloc..datadiv_decode16868916699024037624 ; sym..datadiv_decode16868916699024037624
            0x000b58e0      .dword 0x00098b4c ; reloc..datadiv_decode12802097292201864397 ; sym..datadiv_decode12802097292201864397
            0x000b58e4      .dword 0x00098b50 ; reloc..datadiv_decode12428479046606065387 ; sym..datadiv_decode12428479046606065387
            0x000b58e8      .dword 0x00098b54 ; reloc..datadiv_decode7496105736011033460 ; sym..datadiv_decode7496105736011033460
EOF
RUN

NAME=ELF: arm sh unpatched relocs
ARGS=-e bin.relocs.apply=false
FILE=bins/elf/r2pay-arm32.so
CMDS=<<EOF
ir*~reloc?
s section..init_array
pd 10
EOF
EXPECT=<<EOF
366
            ;-- section..init_array:
            0x000b58c4      .dword 0x00000000                          ; RELOC 32 .datadiv_decode1794556967687044894 @ 0x00004560 ; [15] -rw- section size 364 named .init_array
            0x000b58c8      .dword 0x00000000                          ; RELOC 32 .datadiv_decode12875440098136793118 @ 0x00004570
            0x000b58cc      .dword 0x00000000                          ; RELOC 32 .datadiv_decode11893604691534341392 @ 0x00098028
            0x000b58d0      .dword 0x00008115 ; entry.init0            ; RELOC 32 
            0x000b58d4      .dword 0x00055049 ; entry.init1            ; RELOC 32 
            0x000b58d8      .dword 0x00000000                          ; RELOC 32 .datadiv_decode668687990735969933 @ 0x00098b44
            0x000b58dc      .dword 0x00000000                          ; RELOC 32 .datadiv_decode16868916699024037624 @ 0x00098b48
            0x000b58e0      .dword 0x00000000                          ; RELOC 32 .datadiv_decode12802097292201864397 @ 0x00098b4c
            0x000b58e4      .dword 0x00000000                          ; RELOC 32 .datadiv_decode12428479046606065387 @ 0x00098b50
            0x000b58e8      .dword 0x00000000                          ; RELOC 32 .datadiv_decode7496105736011033460 @ 0x00098b54
EOF
RUN

NAME=ELF: arm64 sh relocs
ARGS=-e bin.relocs.apply=true
FILE=bins/elf/r2pay-arm64.so
CMDS=<<EOF
ir*~reloc?
s section..init_array
pd 10
EOF
EXPECT=<<EOF
264
            ;-- section..init_array:
            ;-- segment.LOAD1:
            0x00126510      .qword 0x0000000000005a6c ; reloc..datadiv_decode9958896245423089702 ; sym..datadiv_decode9958896245423089702 ; [13] -rw- section size 728 named .init_array
            0x00126518      .qword 0x0000000000005a80 ; reloc..datadiv_decode10476194973746341988 ; sym..datadiv_decode10476194973746341988
            0x00126520      .qword 0x00000000000efddc ; reloc..datadiv_decode16323044921667855934 ; sym..datadiv_decode16323044921667855934
            0x00126528      .qword 0x0000000000009080 ; entry.init0
            0x00126530      .qword 0x0000000000077d14 ; entry.init1
            0x00126538      .qword 0x00000000000f22e0 ; reloc..datadiv_decode667225052219618748 ; sym..datadiv_decode667225052219618748
            0x00126540      .qword 0x00000000000f22e4 ; reloc..datadiv_decode8132880250332170398 ; sym..datadiv_decode8132880250332170398
            0x00126548      .qword 0x00000000000f22e8 ; reloc..datadiv_decode3655886617018729963 ; sym..datadiv_decode3655886617018729963
            0x00126550      .qword 0x00000000000f22ec ; reloc..datadiv_decode16406252260792032531 ; sym..datadiv_decode16406252260792032531
            0x00126558      .qword 0x00000000000f22f0 ; reloc..datadiv_decode13403071575248320347 ; sym..datadiv_decode13403071575248320347
EOF
RUN
