NAME=ELF: no version info
FILE=bins/elf/analysis/x64-simple
CMDS=iV
EXPECT=<<EOF
EOF
RUN

NAME=ELF: versioninfo 1
FILE=bins/elf/analysis/serial
CMDS=iV
EXPECT=<<EOF
Version symbols section '.gnu.version' contains 11 entries:
 Addr: 0x00400442  Offset: 0x00000442  Link: 5 (.dynsym)
  0x00000000: 0 (*local*)
  0x00000001: 2 (GLIBC_2.2.5)
  0x00000006: 3 (GLIBC_2.4)
  0x00000007: 2 (GLIBC_2.2.5)
  0x0000000a: 0 (*local*)


Version need section '.gnu.version_r' contains 1 entries:
 Addr: 0x00400458  Offset: 0x00000458  Link to section: 6 (.dynstr)
  0x00000000: Version: 1  File: libc.so.6  Cnt: 2
  0x00000010:   Name: GLIBC_2.4  Flags: none Version: 3
  0x00000020:   Name: GLIBC_2.2.5  Flags: none Version: 2
EOF
RUN

NAME=ELF: versioninfo 2
FILE=bins/elf/analysis/hello-linux-x86_64
CMDS=iV
EXPECT=<<EOF
Version symbols section '.gnu.version' contains 4 entries:
 Addr: 0x0040031e  Offset: 0x0000031e  Link: 5 (.dynsym)
  0x00000000: 0 (*local*)
  0x00000001: 2 (GLIBC_2.2.5)
  0x00000003: 0 (*local*)


Version need section '.gnu.version_r' contains 1 entries:
 Addr: 0x00400328  Offset: 0x00000328  Link to section: 6 (.dynstr)
  0x00000000: Version: 1  File: libc.so.6  Cnt: 1
  0x00000010:   Name: GLIBC_2.2.5  Flags: none Version: 2
EOF
RUN


NAME=ELF: versioninfo name with control characters
FILE=malloc://524
CMDS=<<EOF
wx 7f454c4602010100000000000000000003003e0001000000000000000000000040000000000000004c010000000000000000000040003800020040000300010001000000040000000000000000000000000000000000000000000000000000000c020000000000000c0200000000000001000000000000000200000004000000b000000000000000b000000000000000b000000000000000500000000000000050000000000000000100000000000000050000000000000000010000000000000a000000000000002a00000000000000f0ffff6f000000002a01000000000000feffff6f000000002c0100000000000000000000000000000000000000000000002e7368737472746162002e676e752e76657273696f6e00565f311b5b324b0a3f652070776e65640a00020001000100000000001000000000000000000000000000020018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000001000000030000000000000000000000000000000000000000010000000000002a000000000000000000000000000000010000000000000000000000000000000b000000ffffff6f000000000000000000000000000000002a010000000000000200000000000000010000000000000001000000000000000000000000000000
oba 0
iV*
.iV*
iVj~{[0].versym[0].entries[0].value}
EOF
EXPECT=<<EOF
2 (V_1\u001b[2K\n?e pwned\n)
EOF
RUN

NAME=ELF: overlapping Verneed records are walked once
FILE=malloc://8784
TIMEOUT=10
CMDS=<<EOF
wx 7f454c4602010100000000000000000003003e00010000000000000000000000400000000000000010010000000000000000000040003800020040000300010001000000040000000000000000000000000000000000000000000000000000005022000000000000502200000000000001000000000000000200000004000000b000000000000000b000000000000000b000000000000000500000000000000050000000000000000100000000000000050000000000000000010000000000000a000000000000001000000000000000f0ffff6f00000000d001000000000000feffff6f00000000500200000000000000000000000000000000000000000000002e7368737472746162000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000003000000000000000000000000000000000000000001000000000000100000000000000000000000000000000100000000000000000000000000000001000000ffffff6f00000000000000000000000000000000d0010000000000008000000000000000010000000000000001000000000000000000000000000000
wX 0200 @ 464!128
wX 04000000 @ 592!8160
oba 0
iI~^class
iV~?GLIBC
EOF
EXPECT=<<EOF
class    ELF64
0
EOF
RUN


NAME=ELF: verdef stops at the last verdaux
# synthetic ELF64, one Verdef with vd_cnt=3 followed by a single Verdaux with vda_next=0
FILE=malloc://388
CMDS=<<EOF
wx 7f454c4602010100000000000000000003003e000100000000000000000000000000000000000000680000000000000000000000400038000000400004000100002e7368737472746162002e64796e737472002e676e752e76657273696f6e5f640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000300000000000000000000000000000000000000400000000000000028000000000000000000000000000000010000000000000000000000000000000b00000003000000000000000000000000000000000000004000000000000000280000000000000000000000000000000100000000000000000000000000000013000000fdffff6f0000000000000000000000000000000068010000000000001c00000000000000020000000100000001000000000000000000000000000000010000000100030000000000140000001c0000000000000000000000
oba
k bin/cur/info/versioninfo/verdef0/verdef0/vd_cnt
k bin/cur/info/versioninfo/verdef0/verdef0/**
EOF
EXPECT=<<EOF
0x3
EOF
RUN

NAME=ELF: verneed entries sharing a vernaux list
# synthetic ELF64, three Verneed with vn_cnt=3 pointing to the same three Vernaux
FILE=malloc://456
CMDS=<<EOF
wx 7f454c4602010100000000000000000003003e000100000000000000000000000000000000000000680000000000000000000000400038000000400004000100002e7368737472746162002e64796e737472002e676e752e76657273696f6e5f640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000300000000000000000000000000000000000000400000000000000028000000000000000000000000000000010000000000000000000000000000000b00000003000000000000000000000000000000000000004000000000000000280000000000000000000000000000000100000000000000000000000000000013000000feffff6f0000000000000000000000000000000068010000000000006000000000000000020000000300000001000000000000000000000000000000010003000100000030000000100000000100030001000000200000001000000001000300010000001000000000000000000000000000020001000000100000000000000000000300010000001000000000000000000004000100000000000000
oba
k bin/cur/info/versioninfo/**
iI~class
EOF
EXPECT=<<EOF
class    ELF64
EOF
RUN
