NAME=oon
FILE=bins/mach0/mac-ls2
CMDS=<<EOF
oon
o
EOF
EXPECT=<<EOF
 4 * r-- 0x00009730 bins/mach0/mac-ls2
EOF
RUN

NAME=oonn
FILE=bins/mach0/mac-ls2
CMDS=<<EOF
pf.~?
oonn
pf.~?
o~?
EOF
EXPECT=<<EOF
0
58
1
EOF
RUN

NAME=om=
FILE=bins/mach0/mac-ls2
BROKEN=1
CMDS=om=
EXPECT=<<EOF

0*  0x100000000 ################-------------- 0x100005000 r-x   3     fmap.TEXT
1   0x100005000 ---------------####----------- 0x100006000 r--   3     fmap.DATA
2   0x100006000 ------------------############ 0x10000a000 r--   3     fmap.LINKEDIT
=>  0x1000011e8 ------------------------------ 0x1000012e8             
EOF
RUN

NAME=obo baddrs
FILE=bins/mach0/mac-ls2
ARGS=-B0x50000
CMDS=<<EOF
s
o bins/mach0/mac-ls
s
obo 3
s
obo 4
s
EOF
EXPECT=<<EOF
0x511e8
0x100001058
0x511e8
0x100001058
EOF
RUN

NAME=oom
FILE=bins/elf/libmagic.so
CMDS=<<EOF
o~?
oom
o~malloc?
EOF
EXPECT=<<EOF
2
1
EOF
RUN

NAME=oi-
FILE=malloc://1024
CMDS=oi-
EXPECT=<<EOF
EOF
RUN

NAME=oi-2
FILE=--
CMDS=o bins/mach0/fatmach0-3true
EXPECT=<<EOF
EOF
RUN

NAME=o-[0]
FILE=malloc://1024
CMDS=o- `o~[0]`;o
EXPECT=<<EOF
EOF
RUN

NAME=oj-
FILE=malloc://1024
CMDS=o- `oj~{[0].fd}`;o
EXPECT=<<EOF
EOF
RUN

NAME=oij-pj
FILE=<<EOF
bins/elf/crackme0x05
bins/elf/crackme0x00b
EOF
CMDS=oij
EXPECT=<<EOF
[{"raised":false,"fd":3,"uri":"bins/elf/crackme0x05","from":0,"writable":false,"size":7656},{"raised":true,"fd":5,"uri":"bins/elf/crackme0x00b","from":0,"writable":false,"size":7375}]
EOF
RUN

NAME=o -
FILE=malloc://1024
CMDS=<<EOF
e file.nowarn=true
e file.loadmethod=append
o -;o~?
EOF
EXPECT=<<EOF
2
EOF
RUN

NAME=om
FILE=malloc://1024
CMDS=<<EOF
om `o~[0]` 0x4000
om~?
EOF
EXPECT=<<EOF
2
EOF
RUN

NAME=om2
FILE=malloc://1024
CMDS=<<EOF
om `o~[0]` 0x4000
om `o~[0]` 0x4000
om~?
EOF
EXPECT=<<EOF
3
EOF
RUN

NAME=omn - crash
FILE=-
CMDS=omn
EXPECT=<<EOF
EOF
RUN

NAME=oob 10
FILE=bins/elf/analysis/hello-linux-x86_64
CMDS=<<EOF
10oob
pi 1
EOF
EXPECT=<<EOF
xor ebp, ebp
EOF
RUN

NAME=oo+ 10
FILE=bins/elf/analysis/hello-linux-x86_64
CMDS=<<EOF
10oo+
pi 1
EOF
EXPECT=<<EOF
xor ebp, ebp
EOF
RUN

NAME=oob consider baddr
FILE=bins/mach0/mac-ls
CMDS=<<EOF
e bin.baddr=0xf00000
k old_v=`ieq`
oob
iI~baddr[1]
ie~vaddr[1]
p8 10 @ entry0
p8 10 @ `k old_v`
EOF
EXPECT=<<EOF
0xf00000
0x00f01058
554889e5415741564155
ffffffffffffffffffff
EOF
RUN

NAME=oob consider laddr 32bit
FILE=bins/mach0/fatmach0-3true
ARGS=-a x86 -b 32
CMDS=<<EOF
e bin.laddr=0x5000
e bin.baddr=-1
oob
iI~laddr[1]
iI~baddr[1]
EOF
EXPECT=<<EOF
0x0
0x1000
EOF
RUN

NAME=oob consider laddr 64bit
FILE=bins/mach0/fatmach0-3true
ARGS=-a x86 -b 64
CMDS=<<EOF
e bin.laddr=0x5000
e bin.baddr=-1
oob
iI~laddr[1]
iI~baddr[1]
EOF
EXPECT=<<EOF
0x0
0x100000000
EOF
RUN

NAME=oob from malloc
FILE=malloc://1024
CMDS=<<EOF
wx 7f454c4601010100b32ae9310000000002000300010000000800200020000000010000000000000000002000010000001b0300001b0300000700000000100000e901000000b0e8a502000049e7551ff1c2a03ff17995d4f3f241adf35954d7a87b543f48e7551ff1c3a03ff179bc17f3795487eb79543fc0b0ddf14b78543ff1b4d41632fc944be0c0563ed179e60b197f563ff190273df179bf3e412aeda9f3595485f579543f1987553ff1914c3df1796722677b743f856aeddaf159548dec91813ef179bd7df379544dc722d1e48491ed09f05954859979543f19c3553ff190733df1795e1fa60b3b519659245e820a2350831d781f8216264d88577a11fb73546c9e0b2646d11b214bd10d3c5ad1092650921c274cd10a315a9c0a744b9e59365ad10d265e921c3011df57747d881c7a11df735412cf59074a921a314c8259751ed13a3b51960b354b8415354b98163a4cdf577a35d1597901d1203b4ad11a3551d10a31519559395ad1003b4a835927509d0c20569e177b5c9e14395a9f0d271f900d744b991c745e9316225ad11435569d59355b950b7a11df7354c511b6cac511c2838b48c9899750f5818854b6c7c55fff99915eb199c552e48b865afb8fc512a4e0c511b6cac511bbc7c81cbbc7c81cbbc7c81cbbc7c81cbbc7c81cbbc7c81cbbc7c81cbbc7c81cbbe0ef65fe839611f9848011fe8b9611f7ca9550e49e8c52e3868443fa93c542fb8b895db6998c4bf3c4cb1f9ca28a41f3ca9016fa86c556f39ec542f9878011f09f8b11e1839159b683911f9ce0bc5ee3ca8650f8ca8f5eff84c55cf3ca8445b693845fff99915ed6849049f38ecb5ee48dc55ee4ca8a5fb6c99654f58e8047d68c9754f3848a55f3c48b54e2e0ef74f89e8043b69e8d54b6ba8442e59d8a43f2cadf11b6cae53196ea3ff17954d6f079543f414894b632c950f271bae4d6f079543fd24894b63287978ff2b4d4fc41f092b606f08d92c0a9ffdd0bbabd3cf179548f393a65ff78baede0f37954fe187bea37f1595492f0bab6c4708a3f3bf92c972d2390b84b00200089c689f7b9a5020000c1e902ad35f179543fabe2f7c3e9010000003231c089c3fec0cd80c3
oba
i~bintype[1]
.ie*
p8 10 @ entry0
EOF
EXPECT=<<EOF
elf
b32ae931000000000200
EOF
RUN

NAME=ob select files
FILE=malloc://1024
CMDS=<<EOF
e scr.null=true
o malloc://512
e scr.null=false
i~file[1]
obo 3
i~file[1]
obo 4
i~file[1]
obo 3
i~file[1]
EOF
EXPECT=<<EOF
malloc://512
malloc://1024
malloc://512
malloc://1024
EOF
RUN

NAME=ob select files binobj
FILE=bins/elf/libmagic.so
CMDS=<<EOF
iiq~?
e scr.null=true
o malloc://1024
e scr.null=false
iiq~?
EOF
EXPECT=<<EOF
38
0
EOF
RUN

NAME=ob select files binobj2
FILE=bins/elf/libmagic.so
CMDS=<<EOF
isq~?
e scr.null=true
o bins/elf/true32
e scr.null=false
isq~?
# raise back
op `o~:0[0]`
isq~?
EOF
EXPECT=<<EOF
408
46
408
EOF
RUN

NAME=ob 0 fix
FILE=<<EOF
bins/elf/_Exit (42)
bins/elf/libverifyPass.so
bins/elf/libc.so.6
EOF
CMDS=<<EOF
ob~[0-1]
?e
ob 1; i~^fd
ob 2; i~^fd
ob 0; i~^fd
EOF
EXPECT=<<EOF
0 3
1 4
2 6

fd       4
fd       6
fd       3
EOF
RUN

NAME=o:
FILE=-
CMDS=<<EOF
wx 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
s 0x10
px 16~:1
?e
o:
px 16~:1
?e
om
?e
omp 1
px 16~:1
EOF
EXPECT=<<EOF
0x00000010  1011 1213 1415 1617 1819 1a1b 1c1d 1e1f  ................

0x00000010  2021 2223 2425 2627 2829 2a2b 2c2d 2e2f   !"#$%&'()*+,-./

 2 fd: 4 +0x00000000 0x00000000 - 0x000000ff rwx 
 1 fd: 3 +0x00000000 0x00000000 - 0x000001ff rwx 

0x00000010  1011 1213 1415 1617 1819 1a1b 1c1d 1e1f  ................
EOF
RUN

NAME=o: ob fix
FILE=--
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
o: 1024
ob
EOF
EXPECT=<<EOF
0 3 x86-64 ba:0x00000000 sz:1024 malloc://1024
EOF
RUN

NAME=o: obj
FILE=-
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
obj~{}
EOF
EXPECT=<<EOF
[
  {
    "name": "malloc://512",
    "iofd": 3,
    "bfid": 0,
    "size": 512,
    "obj": {
      "arch": "x86",
      "bits": 64,
      "binoffset": 0,
      "objsize": 512
    }
  }
]
EOF
RUN

NAME=o+ writable maps fix
FILE=--
CMDS=<<EOF
o+ bins/elf/ls
om
# Possible parallelism problem
# ?e
# pv1
# $old=`pv1`
# wx 0x90
# pv1
# wx `$old?`
# pv1
EOF
EXPECT=<<EOF
 5 fd: 3 +0x00000000 0x00000000 - 0x0000347f rwx fmap.LOAD0
 4 fd: 3 +0x00004000 0x00004000 - 0x00016790 rwx fmap.LOAD1
 3 fd: 3 +0x00017000 0x00017000 - 0x0001f7bf rwx fmap.LOAD2
 2 fd: 3 +0x00020050 0x00021050 - 0x00022267 rwx fmap.LOAD3
 1 fd: 4 +0x00000000 0x00022268 - 0x00023557 rw- mmap.LOAD3
EOF
RUN

NAME=o-*
FILE=-
CMDS=<<EOF
o -
o-*
o~?
EOF
EXPECT=<<EOF
0
EOF
RUN

NAME=o-3
FILE=-
CMDS=<<EOF
o -
o-3
o~?
EOF
EXPECT=<<EOF
1
EOF
RUN

NAME=oc
FILE=bins/elf/true32
CMDS=<<EOF
i
oc -
?e --
i
EOF
EXPECT=<<EOF
fd       3
file     bins/elf/true32
size     0x560c
humansz  21.5K
mode     r-x
format   elf
iorw     false
block    0x100
type     EXEC (Executable file)
arch     x86
baddr    0x8048000
binsz    20668
bintype  elf
bits     32
canary   true
class    ELF32
crypto   false
endian   little
havecode true
intrp    /lib/ld-linux.so.2
laddr    0x0
lang     c
linenum  false
lsyms    false
machine  Intel 80386
maxopsz  16
minopsz  1
nx       true
os       linux
pcalign  0
pic      false
relocs   false
relro    partial
rpath    NONE
sanitiz  false
static   false
stripped true
subsys   linux
va       true
--
fd       3
file     malloc://512
size     0x200
humansz  512
mode     rwx
format   any
iorw     true
block    0x100

EOF
RUN
