mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 13:49:50 +00:00
c1c54be39e
This change is to ease the switch to the new parser and make the syntax more consistent and easy. As things were before this patch, ',' could be part of an argument of a command, but at the same time it was used as a separator when defining a new macro. This difference in how `,` is interpreter, makes parsing commands harder, as grep specifiers, arguments, etc. should be parsed differently based on whether they are inside a macro body or not. By switching to using `;` as separator in the macro body, arguments, grep specifiers, etc. can be parsed as they would be outside of a macro body, making the new parser more consistent and easier.
416 lines
11 KiB
Plaintext
416 lines
11 KiB
Plaintext
NAME=32: Elf header size
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
52
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf32
|
|
pfs.elf_header
|
|
EOF
|
|
RUN
|
|
|
|
NAME=64: Elf header size
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
64
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf64
|
|
pfs.elf_header
|
|
EOF
|
|
RUN
|
|
|
|
NAME=32: Elf program header size
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
32
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf32
|
|
pfs.elf_phdr
|
|
EOF
|
|
RUN
|
|
|
|
NAME=64: Elf program header size
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
56
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf64
|
|
pfs.elf_phdr
|
|
EOF
|
|
RUN
|
|
|
|
NAME=32: Elf section header size
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
40
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf32
|
|
pfs.elf_shdr
|
|
EOF
|
|
RUN
|
|
|
|
NAME=64: Elf section header size
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
64
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf64
|
|
pfs.elf_shdr
|
|
EOF
|
|
RUN
|
|
|
|
NAME=32: Multiple section headers
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
sections :
|
|
[
|
|
struct<elf_shdr>
|
|
name : 0x00000000 = 0x00000000
|
|
type : 0x00000004 = type (enum elf_s_type) = 0x0 ; SHT_NULL
|
|
flags : 0x00000008 = flags (enum elf_s_flags_32) = 0x0 ; SF32_None
|
|
addr : 0x0000000c = 0x00000000
|
|
offset : 0x00000010 = 0x00000000
|
|
size : 0x00000014 = 0x00000000
|
|
link : 0x00000018 = 0x00000000
|
|
info : 0x0000001c = 0x00000000
|
|
addralign : 0x00000020 = 0x00000000
|
|
entsize : 0x00000024 = 0x00000000
|
|
|
|
struct<elf_shdr>
|
|
name : 0x00000028 = 0x00000000
|
|
type : 0x0000002c = type (enum elf_s_type) = 0x0 ; SHT_NULL
|
|
flags : 0x00000030 = flags (enum elf_s_flags_32) = 0x0 ; SF32_None
|
|
addr : 0x00000034 = 0x00000000
|
|
offset : 0x00000038 = 0x00000000
|
|
size : 0x0000003c = 0x00000000
|
|
link : 0x00000040 = 0x00000000
|
|
info : 0x00000044 = 0x00000000
|
|
addralign : 0x00000048 = 0x00000000
|
|
entsize : 0x0000004c = 0x00000000
|
|
]
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf32
|
|
pf [2]? (elf_shdr)sections
|
|
EOF
|
|
RUN
|
|
|
|
NAME=64: Multiple section headers
|
|
FILE=malloc://1024
|
|
EXPECT=<<EOF
|
|
sections :
|
|
[
|
|
struct<elf_shdr>
|
|
name : 0x00000000 = 0x00000000
|
|
type : 0x00000004 = type (enum elf_s_type) = 0x0 ; SHT_NULL
|
|
flags : 0x00000008 = flags (enum elf_s_flags_64) = 0x0 ; SF64_None
|
|
addr : 0x00000010 = (qword)0x0000000000000000
|
|
offset : 0x00000018 = (qword)0x0000000000000000
|
|
size : 0x00000020 = (qword)0x0000000000000000
|
|
link : 0x00000028 = 0x00000000
|
|
info : 0x0000002c = 0x00000000
|
|
addralign : 0x00000030 = (qword)0x0000000000000000
|
|
entsize : 0x00000038 = (qword)0x0000000000000000
|
|
|
|
struct<elf_shdr>
|
|
name : 0x00000040 = 0x00000000
|
|
type : 0x00000044 = type (enum elf_s_type) = 0x0 ; SHT_NULL
|
|
flags : 0x00000048 = flags (enum elf_s_flags_64) = 0x0 ; SF64_None
|
|
addr : 0x00000050 = (qword)0x0000000000000000
|
|
offset : 0x00000058 = (qword)0x0000000000000000
|
|
size : 0x00000060 = (qword)0x0000000000000000
|
|
link : 0x00000068 = 0x00000000
|
|
info : 0x0000006c = 0x00000000
|
|
addralign : 0x00000070 = (qword)0x0000000000000000
|
|
entsize : 0x00000078 = (qword)0x0000000000000000
|
|
]
|
|
EOF
|
|
CMDS=<<EOF
|
|
pfo elf64
|
|
pf [2]? (elf_shdr)sections
|
|
EOF
|
|
RUN
|
|
|
|
NAME=Issue 5640 pfj produce wrong json
|
|
FILE=../bins/elf/analysis/main
|
|
EXPECT=<<EOF
|
|
[{"name":"","type":"elf_phdr","offset":64,"value":[{"name":"type","type":"E","offset":64,"value":6,"label":"PT_PHDR","enum":"elf_p_type"},{"name":"flags","type":"E","offset":68,"value":5,"label":"PF_Read_Exec","enum":"elf_p_flags"},{"name":"offset","type":"q","offset":72,"value":64},{"name":"vaddr","type":"q","offset":80,"value":4194368},{"name":"paddr","type":"q","offset":88,"value":4194368},{"name":"filesz","type":"q","offset":96,"value":448},{"name":"memsz","type":"q","offset":104,"value":448},{"name":"align","type":"q","offset":112,"value":8}]}]
|
|
EOF
|
|
ARGS=-nn
|
|
CMDS=pfj {1}? (elf_phdr) @ 0x0000000000000040
|
|
RUN
|
|
|
|
NAME=32: Elf header
|
|
FILE=../bins/elf/analysis/tiny1
|
|
CMDS=<<EOF
|
|
pfo elf32
|
|
pf.elf_header @ 0x8048000
|
|
EOF
|
|
EXPECT=<<EOF
|
|
ident :
|
|
struct<elf_ident>
|
|
magic : 0x08048000 = "\x7fELF"
|
|
class : 0x08048004 = class (enum elf_class) = 0x1 ; ELFCLASS32
|
|
data : 0x08048005 = data (enum elf_data) = 0x1 ; ELFDATA2LSB
|
|
version : 0x08048006 = version (enum elf_hdr_version) = 0x1 ; EV_CURRENT
|
|
type : 0x08048010 = type (enum elf_type) = 0x2 ; ET_EXEC
|
|
machine : 0x08048012 = machine (enum elf_machine) = 0x3 ; EM_386
|
|
version : 0x08048014 = version (enum elf_obj_version) = 0x1 ; EV_CURRENT
|
|
entry : 0x08048018 = 0x08048054
|
|
phoff : 0x0804801c = 0x00000034
|
|
shoff : 0x08048020 = 0x00000000
|
|
flags : 0x08048024 = 0x00000000
|
|
ehsize : 0x08048028 = 0x0034
|
|
phentsize : 0x0804802a = 0x0020
|
|
phnum : 0x0804802c = 0x0001
|
|
shentsize : 0x0804802e = 0x0000
|
|
shnum : 0x08048030 = 0x0000
|
|
shstrndx : 0x08048032 = 0x0000
|
|
EOF
|
|
RUN
|
|
|
|
NAME=64: Elf header
|
|
FILE=../bins/elf/analysis/x64-simple
|
|
CMDS=<<EOF
|
|
pfo elf64
|
|
pf.elf_header @ `i~baddr[1]`
|
|
EOF
|
|
EXPECT=<<EOF
|
|
ident :
|
|
struct<elf_ident>
|
|
magic : 0x00400000 = "\x7fELF"
|
|
class : 0x00400004 = class (enum elf_class) = 0x2 ; ELFCLASS64
|
|
data : 0x00400005 = data (enum elf_data) = 0x1 ; ELFDATA2LSB
|
|
version : 0x00400006 = version (enum elf_hdr_version) = 0x1 ; EV_CURRENT
|
|
type : 0x00400010 = type (enum elf_type) = 0x2 ; ET_EXEC
|
|
machine : 0x00400012 = machine (enum elf_machine) = 0x3e ; EM_X86_64
|
|
version : 0x00400014 = version (enum elf_obj_version) = 0x1 ; EV_CURRENT
|
|
entry : 0x00400018 = (qword)0x0000000000400080
|
|
phoff : 0x00400020 = (qword)0x0000000000000040
|
|
shoff : 0x00400028 = (qword)0x00000000000000a8
|
|
flags : 0x00400030 = 0x00000000
|
|
ehsize : 0x00400034 = 0x0040
|
|
phentsize : 0x00400036 = 0x0038
|
|
phnum : 0x00400038 = 0x0001
|
|
shentsize : 0x0040003a = 0x0040
|
|
shnum : 0x0040003c = 0x0003
|
|
shstrndx : 0x0040003e = 0x0002
|
|
EOF
|
|
RUN
|
|
|
|
NAME=32: -nn elf header
|
|
FILE=../bins/elf/analysis/tiny1
|
|
ARGS=-nn
|
|
CMDS=<<EOF
|
|
e io.va=0
|
|
pf.elf_header @ elf_header
|
|
?e
|
|
pfj.elf_header @ elf_header ~{}
|
|
EOF
|
|
EXPECT=<<EOF
|
|
ident :
|
|
struct<elf_ident>
|
|
magic : 0x00000000 = "\x7fELF"
|
|
class : 0x00000004 = class (enum elf_class) = 0x1 ; ELFCLASS32
|
|
data : 0x00000005 = data (enum elf_data) = 0x1 ; ELFDATA2LSB
|
|
version : 0x00000006 = version (enum elf_hdr_version) = 0x1 ; EV_CURRENT
|
|
type : 0x00000010 = type (enum elf_type) = 0x2 ; ET_EXEC
|
|
machine : 0x00000012 = machine (enum elf_machine) = 0x3 ; EM_386
|
|
version : 0x00000014 = version (enum elf_obj_version) = 0x1 ; EV_CURRENT
|
|
entry : 0x00000018 = 0x08048054
|
|
phoff : 0x0000001c = 0x00000034
|
|
shoff : 0x00000020 = 0x00000000
|
|
flags : 0x00000024 = 0x00000000
|
|
ehsize : 0x00000028 = 0x0034
|
|
phentsize : 0x0000002a = 0x0020
|
|
phnum : 0x0000002c = 0x0001
|
|
shentsize : 0x0000002e = 0x0000
|
|
shnum : 0x00000030 = 0x0000
|
|
shstrndx : 0x00000032 = 0x0000
|
|
|
|
[
|
|
{
|
|
"name": "ident",
|
|
"type": "elf_ident",
|
|
"offset": 0,
|
|
"value": [
|
|
{
|
|
"name": "magic",
|
|
"type": "z",
|
|
"offset": 0,
|
|
"value": "\u007fELF"
|
|
},
|
|
{
|
|
"name": "class",
|
|
"type": "E",
|
|
"offset": 4,
|
|
"value": 1,
|
|
"label": "ELFCLASS32",
|
|
"enum": "elf_class"
|
|
},
|
|
{
|
|
"name": "data",
|
|
"type": "E",
|
|
"offset": 5,
|
|
"value": 1,
|
|
"label": "ELFDATA2LSB",
|
|
"enum": "elf_data"
|
|
},
|
|
{
|
|
"name": "version",
|
|
"type": "E",
|
|
"offset": 6,
|
|
"value": 1,
|
|
"label": "EV_CURRENT",
|
|
"enum": "elf_hdr_version"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "type",
|
|
"type": "E",
|
|
"offset": 16,
|
|
"value": 2,
|
|
"label": "ET_EXEC",
|
|
"enum": "elf_type"
|
|
},
|
|
{
|
|
"name": "machine",
|
|
"type": "E",
|
|
"offset": 18,
|
|
"value": 3,
|
|
"label": "EM_386",
|
|
"enum": "elf_machine"
|
|
},
|
|
{
|
|
"name": "version",
|
|
"type": "E",
|
|
"offset": 20,
|
|
"value": 1,
|
|
"label": "EV_CURRENT",
|
|
"enum": "elf_obj_version"
|
|
},
|
|
{
|
|
"name": "entry",
|
|
"type": "x",
|
|
"offset": 24,
|
|
"value": 134512724
|
|
},
|
|
{
|
|
"name": "phoff",
|
|
"type": "x",
|
|
"offset": 28,
|
|
"value": 52
|
|
},
|
|
{
|
|
"name": "shoff",
|
|
"type": "x",
|
|
"offset": 32,
|
|
"value": 0
|
|
},
|
|
{
|
|
"name": "flags",
|
|
"type": "x",
|
|
"offset": 36,
|
|
"value": 0
|
|
},
|
|
{
|
|
"name": "ehsize",
|
|
"type": "w",
|
|
"offset": 40,
|
|
"value": 52
|
|
},
|
|
{
|
|
"name": "phentsize",
|
|
"type": "w",
|
|
"offset": 42,
|
|
"value": 32
|
|
},
|
|
{
|
|
"name": "phnum",
|
|
"type": "w",
|
|
"offset": 44,
|
|
"value": 1
|
|
},
|
|
{
|
|
"name": "shentsize",
|
|
"type": "w",
|
|
"offset": 46,
|
|
"value": 0
|
|
},
|
|
{
|
|
"name": "shnum",
|
|
"type": "w",
|
|
"offset": 48,
|
|
"value": 0
|
|
},
|
|
{
|
|
"name": "shstrndx",
|
|
"type": "w",
|
|
"offset": 50,
|
|
"value": 0
|
|
}
|
|
]
|
|
EOF
|
|
RUN
|
|
|
|
NAME=64: -nn elf header
|
|
FILE=../bins/elf/analysis/x64-simple
|
|
ARGS=-nn
|
|
CMDS=<<EOF
|
|
e io.va=0
|
|
pf.elf_header @ elf_header
|
|
EOF
|
|
EXPECT=<<EOF
|
|
ident :
|
|
struct<elf_ident>
|
|
magic : 0x00000000 = "\x7fELF"
|
|
class : 0x00000004 = class (enum elf_class) = 0x2 ; ELFCLASS64
|
|
data : 0x00000005 = data (enum elf_data) = 0x1 ; ELFDATA2LSB
|
|
version : 0x00000006 = version (enum elf_hdr_version) = 0x1 ; EV_CURRENT
|
|
type : 0x00000010 = type (enum elf_type) = 0x2 ; ET_EXEC
|
|
machine : 0x00000012 = machine (enum elf_machine) = 0x3e ; EM_X86_64
|
|
version : 0x00000014 = version (enum elf_obj_version) = 0x1 ; EV_CURRENT
|
|
entry : 0x00000018 = (qword)0x0000000000400080
|
|
phoff : 0x00000020 = (qword)0x0000000000000040
|
|
shoff : 0x00000028 = (qword)0x00000000000000a8
|
|
flags : 0x00000030 = 0x00000000
|
|
ehsize : 0x00000034 = 0x0040
|
|
phentsize : 0x00000036 = 0x0038
|
|
phnum : 0x00000038 = 0x0001
|
|
shentsize : 0x0000003a = 0x0040
|
|
shnum : 0x0000003c = 0x0003
|
|
shstrndx : 0x0000003e = 0x0002
|
|
EOF
|
|
RUN
|
|
|
|
NAME=pf elf_header times fix
|
|
FILE=-
|
|
CMDS=<<EOF
|
|
pfo elf32
|
|
pf? elf_header
|
|
pfs.elf_header
|
|
?e
|
|
wz `pf? elf_header`
|
|
(pfelf num; pf.elf_header {$0}`psz`; pf? elf_header; pfs.elf_header)
|
|
.(pfelf 1)
|
|
?e
|
|
.(pfelf 2)
|
|
EOF
|
|
EXPECT=<<EOF
|
|
?[2]E[2]E[4]Exxxxwwwwww (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx
|
|
52
|
|
|
|
{1}?[2]E[2]E[4]Exxxxwwwwww (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx
|
|
52
|
|
|
|
{2}?[2]E[2]E[4]Exxxxwwwwww (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx
|
|
104
|
|
EOF
|
|
RUN
|