NAME=ELF: core segments
FILE=bins/elf/analysis/core.1159
CMDS=iSS~?
EXPECT=<<EOF
20
EOF
RUN

NAME=ELF: core sections with reg name
FILE=bins/elf/analysis/core.1159
BROKEN=1
CMDS=iS~?reg;iS
EXPECT=<<EOF
6
EOF
RUN

NAME=core registers
FILE=bins/elf/analysis/core.1159
CMDS=ar
EXPECT=<<EOF
rax = 0x0000000000000000
rbx = 0x0000000000000000
rcx = 0x0000000000000000
rdx = 0x00007ffe70e05a58
rsi = 0x00007ffe70e05a48
rdi = 0x0000000000000001
r8 = 0x00007f594881de10
r9 = 0x00007f5948831660
r10 = 0x000000000000083e
r11 = 0x00007f594849d590
r12 = 0x00000000004003c0
r13 = 0x00007ffe70e05a40
r14 = 0x0000000000000000
r15 = 0x0000000000000000
rip = 0x00000000004004c6
rbp = 0x00007ffe70e05950
rflags = 0x0000000000010246
rsp = 0x00007ffe70e05950
EOF
RUN

NAME=segment comment
FILE=bins/elf/analysis/core.1159
CMDS=<<EOF
e asm.bytes=true
e asm.cmt.right=true
pd 1 @ 0x7ffe70f68000
echo
e asm.cmt.right=false
pd 1 @ 0x7ffe70f68000
EOF
EXPECT=<<EOF
            ;-- segment.LOAD14:
        ,=< 0x7ffe70f68000      7f45           jnle  0x7ffe70f68047    ; [15] -r-x segment size 8192 named LOAD14

            ; [15] -r-x segment size 8192 named LOAD14
            ;-- segment.LOAD14:
        ,=< 0x7ffe70f68000      7f45           jnle 0x7ffe70f68047
EOF
RUN

NAME=core maps linux x86
FILE=bins/elf/core/core-linux-x86
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00001000 0x56621000 - 0x56621fff r-- fmap./home/florian/dev/crash/crash-linux-x86
 2 fd: 4 +0x00000000 0x56622000 - 0x56622fff r-x mmap./home/florian/dev/crash/crash-linux-x86
 3 fd: 5 +0x00000000 0x56623000 - 0x56623fff r-- mmap./home/florian/dev/crash/crash-linux-x86
 4 fd: 3 +0x00002000 0x56624000 - 0x56624fff r-- fmap./home/florian/dev/crash/crash-linux-x86
 5 fd: 3 +0x00003000 0x56625000 - 0x56625fff r-- fmap./home/florian/dev/crash/crash-linux-x86
 6 fd: 6 +0x00000000 0xf7d51000 - 0xf7d6cfff r-- mmap./usr/lib32/libc-2.33.so
 7 fd: 3 +0x00004000 0xf7d50000 - 0xf7d50fff r-- fmap./usr/lib32/libc-2.33.so
 8 fd: 7 +0x00000000 0xf7d6d000 - 0xf7ec9fff r-x mmap./usr/lib32/libc-2.33.so
 9 fd: 8 +0x00000000 0xf7eca000 - 0xf7f3bfff r-- mmap./usr/lib32/libc-2.33.so
10 fd: 5 +0x00000000 0xf7f3c000 - 0xf7f3cfff r-- mmap./usr/lib32/libc-2.33.so
11 fd: 3 +0x00005000 0xf7f3d000 - 0xf7f3efff r-- fmap./usr/lib32/libc-2.33.so
12 fd: 3 +0x00007000 0xf7f3f000 - 0xf7f40fff r-- fmap./usr/lib32/libc-2.33.so
13 fd: 3 +0x00009000 0xf7f41000 - 0xf7f49fff r-- fmap.LOAD11
14 fd: 3 +0x00012000 0xf7f97000 - 0xf7f9afff r-- fmap.LOAD12
15 fd: 3 +0x00016000 0xf7f9b000 - 0xf7f9cfff r-x fmap.LOAD13
16 fd: 3 +0x00018000 0xf7f9d000 - 0xf7f9dfff r-- fmap./usr/lib32/ld-2.33.so
17 fd: 9 +0x00000000 0xf7f9e000 - 0xf7fbffff r-x mmap./usr/lib32/ld-2.33.so
18 fd: 10 +0x00000000 0xf7fc0000 - 0xf7fccfff r-- mmap./usr/lib32/ld-2.33.so
19 fd: 3 +0x00019000 0xf7fcd000 - 0xf7fcefff r-- fmap./usr/lib32/ld-2.33.so
20 fd: 3 +0x0001b000 0xf7fcf000 - 0xf7fcffff r-- fmap./usr/lib32/ld-2.33.so
21 fd: 3 +0x0001c000 0xffb6b000 - 0xffb8bfff r-- fmap.[stack]
EOF
RUN

NAME=core regs linux x86
FILE=bins/elf/core/core-linux-x86
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
oeax = 0xffffffff
eax = 0x56625000
ebx = 0x00000000
ecx = 0xffb8a8a0
edx = 0x00000000
esi = 0x00000001
edi = 0x56622060
esp = 0xffb8a870
ebp = 0xffb8a888
eip = 0x566221c3
eflags = 0x00010216
EOF
RUN

NAME=core maps linux x86_64
FILE=bins/elf/core/core-linux-x86_64
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00002000 0x56149dfaf000 - 0x56149dfaffff r-- fmap.bins/elf/core/crash-linux-x86_64
 2 fd: 4 +0x00000000 0x56149dfb0000 - 0x56149dfb0fff r-x mmap.bins/elf/core/crash-linux-x86_64
 3 fd: 5 +0x00000000 0x56149dfb1000 - 0x56149dfb1fff r-- mmap.bins/elf/core/crash-linux-x86_64
 4 fd: 3 +0x00003000 0x56149dfb2000 - 0x56149dfb2fff r-- fmap.bins/elf/core/crash-linux-x86_64
 5 fd: 3 +0x00004000 0x56149dfb3000 - 0x56149dfb3fff r-- fmap.bins/elf/core/crash-linux-x86_64
 6 fd: 3 +0x00005000 0x7f582fa2e000 - 0x7f582fa2ffff r-- fmap.LOAD5
 7 fd: 6 +0x00000000 0x7f582fa31000 - 0x7f582fa55fff r-- mmap./usr/lib/libc-2.33.so
 8 fd: 3 +0x00007000 0x7f582fa30000 - 0x7f582fa30fff r-- fmap./usr/lib/libc-2.33.so
 9 fd: 7 +0x00000000 0x7f582fa56000 - 0x7f582fba1fff r-x mmap./usr/lib/libc-2.33.so
10 fd: 8 +0x00000000 0x7f582fba2000 - 0x7f582fbedfff r-- mmap./usr/lib/libc-2.33.so
11 fd: 3 +0x00008000 0x7f582fbee000 - 0x7f582fbf0fff r-- fmap./usr/lib/libc-2.33.so
12 fd: 3 +0x0000b000 0x7f582fbf1000 - 0x7f582fbf3fff r-- fmap./usr/lib/libc-2.33.so
13 fd: 3 +0x0000e000 0x7f582fbf4000 - 0x7f582fbfefff r-- fmap.LOAD11
14 fd: 3 +0x00019000 0x7f582fc4c000 - 0x7f582fc4cfff r-- fmap./usr/lib/ld-2.33.so
15 fd: 9 +0x00000000 0x7f582fc4d000 - 0x7f582fc70fff r-x mmap./usr/lib/ld-2.33.so
16 fd: 10 +0x00000000 0x7f582fc71000 - 0x7f582fc79fff r-- mmap./usr/lib/ld-2.33.so
17 fd: 3 +0x0001a000 0x7f582fc7b000 - 0x7f582fc7cfff r-- fmap./usr/lib/ld-2.33.so
18 fd: 3 +0x0001c000 0x7f582fc7d000 - 0x7f582fc7efff r-- fmap./usr/lib/ld-2.33.so
19 fd: 3 +0x0001e000 0x7ffc8352d000 - 0x7ffc8354dfff r-- fmap.[stack]
20 fd: 3 +0x0003f000 0x7ffc83558000 - 0x7ffc8355bfff r-- fmap.LOAD18
21 fd: 3 +0x00043000 0x7ffc8355c000 - 0x7ffc8355dfff r-x fmap.LOAD19
22 fd: 3 +0x00045000 0xffffffffff600000 - 0xffffffffff600fff r-x fmap.LOAD20
EOF
RUN

NAME=core regs linux x86_64
FILE=bins/elf/core/core-linux-x86_64
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
rax = 0x0000000000000000
rbx = 0x000056149dfb0170
rcx = 0x00007f582fbf1598
rdx = 0x00007ffc8354c1c8
rsi = 0x00007ffc8354c1b8
rdi = 0x0000000000000001
r8 = 0x0000000000000000
r9 = 0x00007f582fc5c070
r10 = 0x00000000069682ac
r11 = 0x0000000000000202
r12 = 0x000056149dfb0040
r13 = 0x0000000000000000
r14 = 0x0000000000000000
r15 = 0x0000000000000000
rip = 0x000056149dfb014d
rbp = 0x00007ffc8354c0c0
rflags = 0x0000000000010202
rsp = 0x00007ffc8354c0b0
EOF
RUN

NAME=core maps linux arm64
FILE=bins/elf/core/core-linux-arm64
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00001000 0x558ce37000 - 0x558ce37fff r-x fmap.bins/elf/core/crash-linux-arm64
 2 fd: 3 +0x00002000 0x558ce47000 - 0x558ce47fff r-- fmap.bins/elf/core/crash-linux-arm64
 3 fd: 3 +0x00003000 0x558ce48000 - 0x558ce48fff r-- fmap.bins/elf/core/crash-linux-arm64
 4 fd: 4 +0x00000000 0x7f8bd61000 - 0x7f8bebafff r-x mmap./usr/lib/libc-2.32.so
 5 fd: 3 +0x00004000 0x7f8bd60000 - 0x7f8bd60fff r-x fmap./usr/lib/libc-2.32.so
 6 fd: 5 +0x00000000 0x7f8bebb000 - 0x7f8becafff r-- mmap./usr/lib/libc-2.32.so
 7 fd: 3 +0x00005000 0x7f8becb000 - 0x7f8becdfff r-- fmap./usr/lib/libc-2.32.so
 8 fd: 3 +0x00008000 0x7f8bece000 - 0x7f8bed0fff r-- fmap./usr/lib/libc-2.32.so
 9 fd: 3 +0x0000b000 0x7f8bed1000 - 0x7f8bed3fff r-- fmap.LOAD7
10 fd: 6 +0x00000000 0x7f8bef9000 - 0x7f8bf19fff r-x mmap./usr/lib/ld-2.32.so
11 fd: 3 +0x0000e000 0x7f8bef8000 - 0x7f8bef8fff r-x fmap./usr/lib/ld-2.32.so
12 fd: 3 +0x0000f000 0x7f8bf26000 - 0x7f8bf27fff r-- fmap.LOAD9
13 fd: 3 +0x00011000 0x7f8bf28000 - 0x7f8bf28fff r-- fmap.LOAD10
14 fd: 3 +0x00012000 0x7f8bf29000 - 0x7f8bf29fff r-x fmap.LOAD11
15 fd: 3 +0x00013000 0x7f8bf2a000 - 0x7f8bf2afff r-- fmap./usr/lib/ld-2.32.so
16 fd: 3 +0x00014000 0x7f8bf2b000 - 0x7f8bf2cfff r-- fmap./usr/lib/ld-2.32.so
17 fd: 3 +0x00016000 0x7ff5e96000 - 0x7ff5eb6fff r-- fmap.[stack]
EOF
RUN

NAME=core regs linux arm64
FILE=bins/elf/core/core-linux-arm64
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
x0 = 0x0000000000000000
x1 = 0x0000007ff5eb5ed8
x2 = 0x0000007ff5eb5ee8
x3 = 0x000000558ce37744
x4 = 0x0000000000000000
x5 = 0x2bc88a8092e0763f
x6 = 0x0000007f8bed0590
x7 = 0x0000004554415649
x8 = 0x00000000000000d7
x9 = 0x0000000000000000
x10 = 0x0000000000000000
x11 = 0x0000000000000000
x12 = 0x0000007f8bd67310
x13 = 0x0000000000000000
x14 = 0x0000000000000000
x15 = 0x000000006fffff47
x16 = 0x0000000000000000
x17 = 0x0000000000000000
x18 = 0x0000000000000000
x19 = 0x000000558ce37780
x20 = 0x0000000000000000
x21 = 0x000000558ce37630
x22 = 0x0000000000000000
x23 = 0x0000000000000000
x24 = 0x0000000000000000
x25 = 0x0000000000000000
x26 = 0x0000000000000000
x27 = 0x0000000000000000
x28 = 0x0000000000000000
x29 = 0x0000007ff5eb5d60
x30 = 0x0000007f8bd84538
tmp = 0x0000000000000000
wzr = 0x00000000
fp = 0x0000007ff5eb5d60
lr = 0x0000007f8bd84538
sp = 0x0000007ff5eb5d60
pc = 0x000000558ce37754
zr = 0x0000000000000000
xzr = 0x0000000000000000
pstate = 0x0000000000000000
EOF
RUN

NAME=core maps linux arm32
FILE=bins/elf/core/core-linux-arm32
CMDS=<<EOF
oml
EOF
EXPECT=<<EOF
 1 fd: 3 +0x00001000 0x00010000 - 0x00010fff r-x fmap./home/pi/crash/crash-linux-arm32
 2 fd: 3 +0x00002000 0x00020000 - 0x00020fff r-- fmap./home/pi/crash/crash-linux-arm32
 3 fd: 3 +0x00003000 0x00021000 - 0x00021fff r-- fmap./home/pi/crash/crash-linux-arm32
 4 fd: 4 +0x00000000 0x76e4a000 - 0x76f80fff r-x mmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 5 fd: 3 +0x00004000 0x76e49000 - 0x76e49fff r-x fmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 6 fd: 5 +0x00000000 0x76f81000 - 0x76f90fff r-- mmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 7 fd: 3 +0x00005000 0x76f91000 - 0x76f92fff r-- fmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 8 fd: 3 +0x00007000 0x76f93000 - 0x76f93fff r-- fmap./usr/lib/arm-linux-gnueabihf/libc-2.28.so
 9 fd: 3 +0x00008000 0x76f94000 - 0x76f96fff r-- fmap.LOAD7
10 fd: 6 +0x00000000 0x76f97000 - 0x76f9afff r-x mmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
11 fd: 7 +0x00000000 0x76f9b000 - 0x76fa9fff r-- mmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
12 fd: 3 +0x0000b000 0x76faa000 - 0x76faafff r-- fmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
13 fd: 3 +0x0000c000 0x76fab000 - 0x76fabfff r-- fmap./usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
14 fd: 8 +0x00000000 0x76fad000 - 0x76fcbfff r-x mmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
15 fd: 3 +0x0000d000 0x76fac000 - 0x76facfff r-x fmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
16 fd: 3 +0x0000e000 0x76fda000 - 0x76fdbfff r-- fmap.LOAD13
17 fd: 3 +0x00010000 0x76fdc000 - 0x76fdcfff r-- fmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
18 fd: 3 +0x00011000 0x76fdd000 - 0x76fddfff r-- fmap./usr/lib/arm-linux-gnueabihf/ld-2.28.so
19 fd: 3 +0x00012000 0x7ea6c000 - 0x7ea8cfff r-- fmap.[stack]
20 fd: 3 +0x00033000 0x7eb68000 - 0x7eb68fff r-x fmap.LOAD17
21 fd: 3 +0x00034000 0x7eb69000 - 0x7eb69fff r-- fmap.LOAD18
22 fd: 3 +0x00035000 0x7eb6a000 - 0x7eb6afff r-x fmap.LOAD19
23 fd: 3 +0x00036000 0xffff0000 - 0xffff0fff r-x fmap.LOAD20
EOF
RUN

NAME=core regs linux arm32
FILE=bins/elf/core/core-linux-arm32
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
sb = 0x00000000
sl = 0x76fdd000
fp = 0x7ea8c4f4
ip = 0x7ea8c570
sp = 0x7ea8c4e8
lr = 0x76e60718
pc = 0x00010420
r0 = 0x00000001
r1 = 0x7ea8c644
r2 = 0x7ea8c64c
r3 = 0x00000000
r4 = 0x00000000
r5 = 0x00010444
r6 = 0x00010318
r7 = 0x00000000
r8 = 0x00000000
r9 = 0x00000000
r10 = 0x76fdd000
r11 = 0x7ea8c4f4
r12 = 0x7ea8c570
r13 = 0x7ea8c4e8
r14 = 0x76e60718
r15 = 0x00010420
cpsr = 0x60000010
fpscr = 0x00000000
EOF
RUN

NAME=core regs openbsd sparc64
FILE=bins/elf/core/core-openbsd-sparc64
CMDS=<<EOF
# Output confirmed with readelf
ar
# arF doesn't work (prints nothing) as it looks like.
# I have intentionally not extracted this command into a BROKEN test.
# The issue is that the register layout of the ELF note
# differs between Linux and OpenBSD.
# Especially, the upper FP regs of Sparc64.
# Please ping me if it gets fixed and the registers floating point regs
# are printed here.
# Setting the FP regs arena requires a user defined method to do so.
# Beause just memcpy the bytes won't do it due to the different layout.
# Also check out the comments about the layout at
# elf_notes.c::SPARC32_FPREGS_SIZE and elf_notes.c::SPARC64_OPENBSD_FPREGS_SIZE.
# You can see the difference there.
# Issue:
# https://github.com/rizinorg/rizin/issues/5334
arF
EOF
EXPECT=<<EOF
g0 = 0x0000000082000202
g1 = 0x000000a06ed006d4
g2 = 0x000000a06ed006d8
g3 = 0x000000001518e0e0
g4 = 0x0000000000000000
g5 = 0x0000000000000000
g6 = 0x0000000000000000
g7 = 0xfffffe849aea7d28
o0 = 0x000000000000000c
o1 = 0x0000000000000000
o2 = 0x0000000000000000
o3 = 0x000000a2be486940
o4 = 0x00000400fb3bdee0
o5 = 0x0000000000000009
sp = 0x000000a06ed02206
o7 = 0x0000000000000000
l0 = 0x0000000000000000
l1 = 0x0000000000000000
l2 = 0xfffffe849aea75e1
l3 = 0x000000a06ed021f4
l4 = 0x000000a328709400
l5 = 0x0000000028709400
l6 = 0x0000000000000000
l7 = 0x0000000000000000
i0 = 0x0000000000000000
i1 = 0x0000000000000000
i2 = 0x0000000000000000
i3 = 0x000000a3528060c0
i4 = 0x000000006f004080
i5 = 0xfffffe849aea8008
fp = 0xfffffe849aea8018
i7 = 0x0000000000000000
y = 0x000000a06ed003b0
pc = 0x0000000000000000
npc = 0x0000000000000000
asr = 0x0000000000000000
csr = 0x0000000000000000
asi = 0x0000000000000000
fsr = 0x0000000000000000
EOF
EXPECT_ERR=<<EOF
WARNING: Number of sections is 0.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 0 at 0x40 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 1 at 0x78 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 2 at 0xb0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 3 at 0xe8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 4 at 0x120 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 5 at 0x158 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 6 at 0x190 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 7 at 0x1c8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 8 at 0x200 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 9 at 0x238 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 10 at 0x270 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 11 at 0x2a8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 12 at 0x2e0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 13 at 0x318 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 14 at 0x350 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 15 at 0x388 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 16 at 0x3c0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 17 at 0x3f8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 18 at 0x430 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 19 at 0x468 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 20 at 0x4a0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 21 at 0x4d8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 22 at 0x510 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 23 at 0x548 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 24 at 0x580 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 25 at 0x5b8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 26 at 0x5f0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 27 at 0x628 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 28 at 0x660 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 29 at 0x698 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 30 at 0x6d0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 31 at 0x708 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 32 at 0x740 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 33 at 0x778 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 34 at 0x7b0 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 35 at 0x7e8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 36 at 0x820 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 37 at 0x858 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 38 at 0x890 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 39 at 0x8c8 seems to be invalid.
WARNING: phdr entry: p_offset and p_vaddr are not congruent for p_align.
WARNING: The segment 40 at 0x900 seems to be invalid.
EOF
RUN

NAME=core regs openbsd sparc64
FILE=bins/elf/core/core-linux-sparc64
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
g0 = 0x0000000000000000
g1 = 0x0000000000000001
g2 = 0x0000000000000010
g3 = 0x00000100001021f0
g4 = 0x0000000000000021
g5 = 0x000000000000000f
g6 = 0x0000000083287020
g7 = 0xfffff80100027700
o0 = 0x0000000000000001
o1 = 0x0000000000000000
o2 = 0x0000000000000000
o3 = 0x0000000000000000
o4 = 0x0000000000000000
o5 = 0x0000000000000000
sp = 0x000007feffa00f91
o7 = 0x00000100000009b4
l0 = 0x0000000000000000
l1 = 0x0000000000000000
l2 = 0x0000000000000000
l3 = 0x0000000000000000
l4 = 0x0000000000000000
l5 = 0x0000000000000000
l6 = 0x0000000000000000
l7 = 0x0000010000102000
i0 = 0x0000000000000001
i1 = 0x000007feffa01bf8
i2 = 0x000007feffa01c08
i3 = 0xfffff8010038f1c0
i4 = 0x0000000000000001
i5 = 0x0000000000000001
fp = 0x000007feffa01051
i7 = 0xfffff8010014f128
y = 0x0000000000000000
pc = 0x0000000000000000
npc = 0x0000000000000000
asr = 0x0000000000000000
csr = 0x0000000000000000
asi = 0x0000000000000000
fsr = 0x0000000000000000
EOF
EXPECT_ERR=<<EOF
WARNING: Number of sections is 0.
EOF
RUN

NAME=core regs linux mipsel
FILE=bins/elf/core/core-linux-mips32el-bin-ls
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
zero = 0x00000000
at = 0x824dd370
v0 = 0xffffffff
v1 = 0xffffffff
a0 = 0x555922d0
a1 = 0x55592350
a2 = 0xffffffff
a3 = 0x00000000
t0 = 0x00000000
t1 = 0x8214ad88
t2 = 0x8242de00
t3 = 0xffffffff
t4 = 0x00000000
t5 = 0x77f68e20
t6 = 0x00000000
t7 = 0x77f68e20
s0 = 0x555922d0
s1 = 0x55592190
s2 = 0x00000000
s3 = 0x7fffcbac
s4 = 0x7fffcbb0
s5 = 0xffffffff
s6 = 0x77ffbf04
s7 = 0x00000000
t8 = 0x00000000
t9 = 0x77e33978
k0 = 0x55592190
k1 = 0x00000000
gp = 0x77fb8050
sp = 0x7fffcb90
fp = 0x00000000
ra = 0x77f7ef54
lo = 0x0000000c
hi = 0x00000008
pc = 0x77e33978
badvaddr = 0x77dff180
status = 0x0000a413
cause = 0x10800024
t = 0x00000000
EOF
RUN

NAME=core regs linux mips64el
FILE=bins/elf/core/core-linux-mips64le-bin-ls
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
zero = 0x0000000000000000
at = 0xffffffff82588dac
v0 = 0xffffffffffffffff
v1 = 0xffffffffffffffff
a0 = 0x000000aaaaae2480
a1 = 0xffffffffffffffff
a2 = 0x0000000000000400
a3 = 0x0000000000000000
t0 = 0xfefefefefefefeff
t1 = 0x0000000000000001
t2 = 0x7373737373737373
t3 = 0xffffffffffffffff
t4 = 0x0000000000000000
t5 = 0xffffffff84080018
t6 = 0xffffffff824d85f0
t7 = 0x0000000074786509
s0 = 0x000000aaaaae2480
s1 = 0x000000aaaaae22a0
s2 = 0x0000000000000000
s3 = 0x000000ffffffca10
s4 = 0x000000ffffffca08
s5 = 0xffffffffffffffff
s6 = 0x000000fff7ffae68
s7 = 0x0000000000000000
t8 = 0x0000000000000012
t9 = 0x000000fff7e1d010
k0 = 0x000000aaaaae22a0
k1 = 0x0000000000000000
gp = 0x000000fff7fb8060
sp = 0x000000ffffffca00
fp = 0x0000000000000000
ra = 0x000000fff7f80938
lo = 0x0000000000000007
hi = 0x0000000000000000
pc = 0x000000fff7e1d010
badvaddr = 0x000000fff7f55c28
status = 0x000000000000a4f3
cause = 0x0000000010800024
t = 0x0000000000000000
EOF
RUN

NAME=dm commands on x86-64 core dump
FILE=bins/elf/core/core-linux-x86_64
CMDS=<<EOF
dm~fmap?
dm~mmap?
dmj~{[0]}
dm=~fmap?
dm=~mmap?
echo ----
s 0x56149dfaf000
dm.~0x56149dfaf000
echo ----
dmm~libc
dmm.~bin
dmmj~libc
dmm.j~crash
echo ----
dmi bins/elf/core/crash-linux-x86_64~printf
dmij~{[0]}
dmia bins/elf/core/crash-linux-x86_64~MAGIC
obf bins/elf/core/crash-linux-x86_64 
dmi.~end
echo ----
dmS~.rodata
EOF
EXPECT=<<EOF
15
7
{"map":1,"fd":3,"delta":8192,"from":94646549803008,"to":94646549807104,"perm":"r--","name":"fmap.bins/elf/core/crash-linux-x86_64"}
15
7
----
 1 fd: 3 +0x00002000 0x56149dfaf000 - 0x56149dfaffff r-- fmap.bins/elf/core/crash-linux-x86_64
----
0x7f582fa31000 0x7f582fa56000  /usr/lib/libc-2.33.so
0x56149dfaf000 0x56149dfb0000  bins/elf/core/crash-linux-x86_64
[{"addr":94646549803008,"addr_end":94646549807104,"name":"bins/elf/core/crash-linux-x86_64"},{"addr":140016733065216,"addr_end":140016733216768,"name":"/usr/lib/libc-2.33.so"},{"addr":140016735272960,"addr_end":140016735277056,"name":"/usr/lib/ld-2.33.so"}]
[{"addr":94646549803008,"addr_end":94646549807104,"file":"bins/elf/core/crash-linux-x86_64"}]
----
  2 0x00001030 0x56149dfb0030 GLOBAL FUNC     16     imp.printf
{"addr":94646549803008,"addr_end":94646549807104,"name":"bins/elf/core/crash-linux-x86_64"}
0x00000000 MAGIC      0x00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
 34 ---------- 0x00004038 GLOBAL NOTYPE    0     _end
----
0x00002000   0x8 0x56149dfb1000   0x8   0x0 -r-- crash-linux-x86_64..rodata            PROGBITS   alloc
EOF
RUN

NAME=dm commands on arm64 core dump
FILE=bins/elf/core/core-linux-arm64
CMDS=<<EOF
dm~fmap?
dm~mmap?
dm=~fmap?
dm=~mmap?
echo ----
s 0x558ce37000
dm.~0x558ce37000
echo ----
dmm~libc
dmm.~bin
dmmj~libc
dmm.j~crash
echo ----
dmi bins/elf/core/crash-linux-arm64~printf
dmia bins/elf/core/crash-linux-arm64~MAGIC
obf bins/elf/core/crash-linux-arm64 
dmi.~end
echo ----
dmS~.rodata
EOF
EXPECT=<<EOF
14
3
14
3
----
 1 fd: 3 +0x00001000 0x558ce37000 - 0x558ce37fff r-x fmap.bins/elf/core/crash-linux-arm64
----
0x7f8bd61000 0x7f8bebb000  /usr/lib/libc-2.32.so
0x558ce37000 0x558ce38000  bins/elf/core/crash-linux-arm64
[{"addr":367435935744,"addr_end":367435939840,"name":"bins/elf/core/crash-linux-arm64"},{"addr":547806908416,"addr_end":547808325632,"name":"/usr/lib/libc-2.32.so"},{"addr":547808579584,"addr_end":547808714752,"name":"/usr/lib/ld-2.32.so"}]
[{"addr":367435935744,"addr_end":367435939840,"file":"bins/elf/core/crash-linux-arm64"}]
----
  9 0x00000620 0x558ce37620 GLOBAL FUNC     16     imp.printf
0x00000000 MAGIC      0x00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
 83 ---------- 0x00011038 GLOBAL NOTYPE    0     _bss_end__
----
0x00000818   0xc 0x558ce37818   0xc   0x0 -r-- crash-linux-arm64..rodata            PROGBITS   alloc
EOF
RUN

NAME=dmhg commands on arm64 core dump
FILE=bins/heap/segfault-glibc-aarch64-core
CMDS=<<EOF
dmhg~Arena
dmhga
dmhgb~Bin?
dmhgc @ 0xaaab126cd290~0xaaab126cd2a0
echo ----
dmhgd~Empty
dmhgf~Arena
echo ----
dmhgg~0x410?
dmhgm~malloc_state
EOF
EXPECT=<<EOF
Arena @ 0xffff9a780a50
Main arena  (addr=0xffff9a780a50, lastRemainder=0x0, top=0xaaab126cdae0, next=0xffff9a780a50)
128
0xaaab126cd2a0  0x6e75686320676942  0x617830207461206b   Big chunk at 0xa
----
Fast_bin[01] [size: 0x20] Empty bin
Fast_bin[02] [size: 0x30] Empty bin
Fast_bin[03] [size: 0x40] Empty bin
Fast_bin[04] [size: 0x50] Empty bin
Fast_bin[05] [size: 0x60] Empty bin
Fast_bin[06] [size: 0x70] Empty bin
Fast_bin[07] [size: 0x80] Empty bin
Fast bins in Arena @ 0xffff9a780a50
----
2
malloc_state @ 0xffff9a780a50
struct malloc_state main_arena {
EOF
RUN

NAME=core regs linux alpha
FILE=bins/elf/core/core-linux-alpha
CMDS=<<EOF
ar
EOF
EXPECT=<<EOF
r0 = 0x0000000000000026
r1 = 0x0000000000000000
r2 = 0x000000000000002a
r3 = 0x0000000000000000
r4 = 0x0000000000000000
r5 = 0x0a6400646c726f77
r6 = 0x0000000000000001
r7 = 0x0000000120000ad0
r8 = 0x0000000120000ad5
r9 = 0x0000000120000980
r10 = 0x0000000000000000
r11 = 0x0000000000000000
r12 = 0xffffffffffffffff
r13 = 0x0000000120286a50
r14 = 0x00000001202a2d50
r15 = 0x000000011fc1d4f0
r16 = 0x0000020000218670
r17 = 0x00000001200142a0
r18 = 0x0000000000000026
r19 = 0x0000000000000000
r20 = 0x0000000120000ad0
r21 = 0x4b4c514c44722f25
r22 = 0x0000000000000001
r23 = 0x00000200000d45d4
r24 = 0x0000000000000000
r25 = 0x0000000000000400
r26 = 0x00000001200008f8
r27 = 0x0000000000000000
r28 = 0x00000000000003ff
r29 = 0x000000012001a010
r30 = 0x000000011fc1d4f0
r31 = 0x000000012000090c
lr0 = 0x0000000000000000
lr1 = 0x0000000000000000
fpcr = 0x0000000000000000
EOF
RUN
