# merged: ihq (file x86); ih* (file x86); ihj (file x86); iH (file x86); ig and igh
NAME=ih (file x86)
FILE=bins/elf/analysis/x86-helloworld-gcc
CMDS=<<EOF
ih
?e --
ihq
?e --
ih*
?e --
ihj~{}
?e --
iH
?e --
ig
igh
EOF
EXPECT=<<EOF
0x00000000 0x00000000 0x464c457f ELF
0x00000010 0x00000010 0x00000002 Type
0x00000012 0x00000012 0x00000003 Machine
0x00000014 0x00000014 0x00000001 Version
0x00000018 0x00000018 0x08048300 EntryPoint
0x0000001c 0x0000001c 0x00000034 PhOff
0x00000020 0x00000020 0x000007cc ShOff
0x00000024 0x00000024 0x00000000 Flags
0x00000028 0x00000028 0x00000034 EhSize
0x0000002a 0x0000002a 0x00000020 PhentSize
0x0000002c 0x0000002c 0x00000008 PhNum
0x0000002e 0x0000002e 0x00000028 ShentSize
0x00000030 0x00000030 0x0000001e ShNum
0x00000032 0x00000032 0x0000001b ShrStrndx
--
0x00000000 0x464c457f ELF
0x00000010 0x00000002 Type
0x00000012 0x00000003 Machine
0x00000014 0x00000001 Version
0x00000018 0x08048300 EntryPoint
0x0000001c 0x00000034 PhOff
0x00000020 0x000007cc ShOff
0x00000024 0x00000000 Flags
0x00000028 0x00000034 EhSize
0x0000002a 0x00000020 PhentSize
0x0000002c 0x00000008 PhNum
0x0000002e 0x00000028 ShentSize
0x00000030 0x0000001e ShNum
0x00000032 0x0000001b ShrStrndx
--
'fs+header
'f header.ELF 1 0x00000000
'f header.ELF.value 1 0x464c457f
'@0x0'Cd4
'pf.ELF x
'f header.Type 1 0x00000010
'f header.Type.value 1 0x00000002
'pf.Type w
'f header.Machine 1 0x00000012
'f header.Machine.value 1 0x00000003
'pf.Machine w
'f header.Version 1 0x00000014
'f header.Version.value 1 0x00000001
'@0x14'Cd4
'pf.Version x
'f header.EntryPoint 1 0x00000018
'f header.EntryPoint.value 1 0x08048300
'@0x18'Cd4
'pf.EntryPoint x
'f header.PhOff 1 0x0000001c
'f header.PhOff.value 1 0x00000034
'@0x1c'Cd4
'pf.PhOff x
'f header.ShOff 1 0x00000020
'f header.ShOff.value 1 0x000007cc
'@0x20'Cd4
'pf.ShOff x
'f header.Flags 1 0x00000024
'@0x24'Cd4
'pf.Flags x
'f header.EhSize 1 0x00000028
'f header.EhSize.value 1 0x00000034
'pf.EhSize w
'f header.PhentSize 1 0x0000002a
'f header.PhentSize.value 1 0x00000020
'pf.PhentSize w
'f header.PhNum 1 0x0000002c
'f header.PhNum.value 1 0x00000008
'pf.PhNum w
'f header.ShentSize 1 0x0000002e
'f header.ShentSize.value 1 0x00000028
'pf.ShentSize w
'f header.ShNum 1 0x00000030
'f header.ShNum.value 1 0x0000001e
'pf.ShNum w
'f header.ShrStrndx 1 0x00000032
'f header.ShrStrndx.value 1 0x0000001b
'pf.ShrStrndx w
'fs-
--
[
  {
    "name": "ELF",
    "vaddr": 0,
    "paddr": 0,
    "size": 4,
    "value": 1179403647,
    "format": "x",
    "pf": [
      {
        "type": "x",
        "offset": 0,
        "value": 4294967295
      }
    ]
  },
  {
    "name": "Type",
    "vaddr": 16,
    "paddr": 16,
    "size": 2,
    "value": 2,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 16,
        "value": 65535
      }
    ]
  },
  {
    "name": "Machine",
    "vaddr": 18,
    "paddr": 18,
    "size": 2,
    "value": 3,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 18,
        "value": 65535
      }
    ]
  },
  {
    "name": "Version",
    "vaddr": 20,
    "paddr": 20,
    "size": 4,
    "value": 1,
    "format": "x",
    "pf": [
      {
        "type": "x",
        "offset": 20,
        "value": 4294967295
      }
    ]
  },
  {
    "name": "EntryPoint",
    "vaddr": 24,
    "paddr": 24,
    "size": 4,
    "value": 134513408,
    "format": "x",
    "pf": [
      {
        "type": "x",
        "offset": 24,
        "value": 4294967295
      }
    ]
  },
  {
    "name": "PhOff",
    "vaddr": 28,
    "paddr": 28,
    "size": 4,
    "value": 52,
    "format": "x",
    "pf": [
      {
        "type": "x",
        "offset": 28,
        "value": 4294967295
      }
    ]
  },
  {
    "name": "ShOff",
    "vaddr": 32,
    "paddr": 32,
    "size": 4,
    "value": 1996,
    "format": "x",
    "pf": [
      {
        "type": "x",
        "offset": 32,
        "value": 4294967295
      }
    ]
  },
  {
    "name": "Flags",
    "vaddr": 36,
    "paddr": 36,
    "size": 4,
    "format": "x",
    "pf": [
      {
        "type": "x",
        "offset": 36,
        "value": 4294967295
      }
    ]
  },
  {
    "name": "EhSize",
    "vaddr": 40,
    "paddr": 40,
    "size": 2,
    "value": 52,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 40,
        "value": 65535
      }
    ]
  },
  {
    "name": "PhentSize",
    "vaddr": 42,
    "paddr": 42,
    "size": 2,
    "value": 32,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 42,
        "value": 65535
      }
    ]
  },
  {
    "name": "PhNum",
    "vaddr": 44,
    "paddr": 44,
    "size": 2,
    "value": 8,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 44,
        "value": 65535
      }
    ]
  },
  {
    "name": "ShentSize",
    "vaddr": 46,
    "paddr": 46,
    "size": 2,
    "value": 40,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 46,
        "value": 65535
      }
    ]
  },
  {
    "name": "ShNum",
    "vaddr": 48,
    "paddr": 48,
    "size": 2,
    "value": 30,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 48,
        "value": 65535
      }
    ]
  },
  {
    "name": "ShrStrndx",
    "vaddr": 50,
    "paddr": 50,
    "size": 2,
    "value": 27,
    "format": "w",
    "pf": [
      {
        "type": "w",
        "offset": 50,
        "value": 65535
      }
    ]
  }
]
--
0x00000000  ELF MAGIC   0x464c457f
0x00000010  Type        0x0002
0x00000012  Machine     0x0003
0x00000014  Version     0x00000001
0x00000018  Entrypoint  0x08048300
0x0000001c  PhOff       0x00000034
0x00000020  ShOff       0x000007cc
0x00000024  Flags       0x00000000
0x00000028  EhSize      52
0x0000002a  PhentSize   32
0x0000002c  PhNum       8
0x0000002e  ShentSize   40
0x00000030  ShNum       30
0x00000032  ShrStrndx   27
--
0x00001323
4.8K
EOF
RUN

NAME=iH* emits header commands and applies them
FILE=bins/elf/analysis/x86-helloworld-gcc
CMDS=<<EOF
iH*~header.EntryPoint,pf.EntryPoint
.iH*
?v header.EntryPoint
?v header.EntryPoint.value
EOF
EXPECT=<<EOF
'f header.EntryPoint 1 0x00000018
'f header.EntryPoint.value 1 0x08048300
'pf.EntryPoint x
0x18
0x8048300
EOF
RUN
