NAME=ELF: long symbol names
FILE=bins/elf/analysis/longsym
CMDS=?lq `isq~pata`;?vi
EXPECT=<<EOF
194
EOF
RUN

NAME=ELF: simple.elf - code
FILE=bins/elf/analysis/simple.elf
CMDS=<<EOF
e asm.bytes=true
e asm.sub.names=false
pid 4 @ entry0
EOF
EXPECT=<<EOF
0x08000060   section..text:
0x08000060           b990000008  mov ecx, 0x8000090
0x08000065           ba0d000000  mov edx, 0xd
0x0800006a           bb01000000  mov ebx, 1
0x0800006f           b804000000  mov eax, 4
EOF
RUN

NAME=ELF: asm.flags.middle=0 + local symbols
FILE=bins/elf/analysis/example.elf
CMDS=e asm.flags.middle=0;e asm.bytes=true;pd 3 @ 0x356
EXPECT=<<EOF
        :   0x00000356      00f033f9       bl    sym.app_uart_get
        :   0x0000035a      0028           cmp   r0, 0
        `=< 0x0000035c      fad1           bne   0x354
EOF
RUN

NAME=ELF: asm.flags.middle=1 + local symbols
FILE=bins/elf/analysis/example.elf
CMDS=e asm.flags.middle=1;e asm.bytes=true;pd 3 @ 0x356
EXPECT=<<EOF
        :   0x00000356      00f033f9       bl    sym.app_uart_get
        :   0x0000035a      0028           cmp   r0, 0
        `=< 0x0000035c      fad1           bne   0x354
EOF
RUN

NAME=ELF: asm.flags.middle + local symbols
FILE=bins/elf/analysis/example.elf
CMDS=e asm.bytes=true; pd 3 @ 0x356;
EXPECT=<<EOF
        :   0x00000356      00f033f9       bl    sym.app_uart_get
        :   0x0000035a      0028           cmp   r0, 0
        `=< 0x0000035c      fad1           bne   0x354
EOF
RUN

NAME=ELF: asm.flags.middle2 + local symbols
FILE=bins/elf/analysis/example.elf
CMDS=<<EOF
e asm.bytes=true
e asm.flags.middle=0
pd 3 @ 0x356
EOF
EXPECT=<<EOF
        :   0x00000356      00f033f9       bl    sym.app_uart_get
        :   0x0000035a      0028           cmp   r0, 0
        `=< 0x0000035c      fad1           bne   0x354
EOF
RUN

NAME=ELF: local symbols
FILE=bins/elf/analysis/example.elf
CMDS=is*~d_41
EXPECT=<<EOF
EOF
RUN

NAME=ELF: phdr override
FILE=bins/elf/analysis/phdr-override
CMDS=iiq
EXPECT=<<EOF
printf
__libc_start_main
__gmon_start__
EOF
RUN

NAME=ELF: phdr override 2
FILE=bins/elf/busybox-phdr-shdr
CMDS=ii~OBJ
EXPECT=<<EOF
7   0x00000000 GLOBAL OBJ      __environ
43  0x00000000 GLOBAL OBJ      __ctype_tolower
145 0x00000000 GLOBAL OBJ      __stdout
189 0x00000000 GLOBAL OBJ      stderr
409 0x00000000 GLOBAL OBJ      stdin
410 0x00000000 GLOBAL OBJ      __stdin
417 0x00000000 GLOBAL OBJ      optind
468 0x00000000 GLOBAL OBJ      environ
588 0x00000000 GLOBAL OBJ      optarg
667 0x00000000 GLOBAL OBJ      __ctype_b
706 0x00000000 GLOBAL OBJ      allCountryList
718 0x00000000 GLOBAL OBJ      stdout
EOF
RUN

NAME=ELF: no symbol overwrite
FILE=bins/elf/libc.so.6
CMDS=<<EOF
is~getpid
f~getpid
EOF
EXPECT=<<EOF
581   0x000c9420 0x000c9420 WEAK   FUNC   12        getpid
965   0x000c9420 0x000c9420 GLOBAL FUNC   12        __getpid
3577  0x000c9420 0x000c9420 LOCAL  FUNC   12        __GI___getpid
3807  0x000c9420 0x000c9420 LOCAL  FUNC   12        __GI_getpid
0x000c9420 12 sym.getpid
0x000c9420 12 sym.__getpid
0x000c9420 12 sym.__GI___getpid
0x000c9420 12 sym.__GI_getpid
EOF
RUN
