mirror of
https://github.com/rizinorg/rizin
synced 2026-08-22 20:26:16 -04:00
The ELF section classifier in sections_obj() only marked a section as
data when its name contained "data". As a result .dynstr (type
SHT_STRTAB, SHF_ALLOC) was flagged neither as data nor as containing
strings, so is_data_section() rejected it. Two problems followed:
- the string search (iz, and the default AUTO scan used by -A) skipped
.dynstr, so its strings were never listed (only izz, which scans the
whole file regardless of section flags, showed them);
- because no RZ_META_TYPE_STRING metadata was applied over the region,
the disassembler rendered the NUL-terminated symbol names as code,
e.g. on MIPS "_GLOBAL_OFFSET_TABLE_" decoded to bgtzl/ldr/jalx/...
Mark a section as containing strings when it is mapped into memory
(SHF_ALLOC) and is either a string table (SHT_STRTAB) or carries the
explicit SHF_STRINGS flag. The SHF_ALLOC restriction keeps the loaded
string tables (.dynstr) while leaving the non-allocated .strtab and
.shstrtab to izz, matching the "iz lists the loaded image" semantics.
This is architecture independent; MIPS was simply where the bad
disassembly was first noticed.
Closes #5182
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
266 lines
4.3 KiB
Text
266 lines
4.3 KiB
Text
NAME=p-h out of bounds
|
|
FILE=bins/mach0/mach0-x86-64
|
|
CMDS=<<EOF
|
|
aaa
|
|
p-h @ 0x100001010 @e:search.in=bin.section
|
|
EOF
|
|
EXPECT=<<EOF
|
|
.---------------------------------------------------------------.
|
|
| offset | flags | funcs | cmts | syms | str | sigs | imps |
|
|
)---------------------------------------------------------------(
|
|
| 0x100001010 | 2 | 0 | 1 | 0 | 0 | 0 | 0 |
|
|
)---------------------------------------------------------------(
|
|
| | 2 | 0 | 1 | 0 | 0 | 0 | 0 |
|
|
`---------------------------------------------------------------'
|
|
EOF
|
|
RUN
|
|
|
|
NAME=p-
|
|
FILE=bins/elf/analysis/x86-helloworld-gcc
|
|
CMDS=<<EOF
|
|
s 0x8048000
|
|
e search.in=io.map
|
|
p-
|
|
e search.in=io.maps
|
|
p-
|
|
EOF
|
|
EXPECT=<<EOF
|
|
0x08048000 [^._______ssss_zzzssssii_ss_ss_ss__sz_s____s] 0x0804859c
|
|
0x08048000 [^_szzisszss_____________________________s_s] 0x080496d0
|
|
EOF
|
|
RUN
|
|
|
|
NAME=p- without any file
|
|
FILE=--
|
|
CMDS=p-
|
|
EXPECT=
|
|
RUN
|
|
|
|
NAME=p- with malloc://512
|
|
FILE=malloc://512
|
|
CMDS=p-
|
|
EXPECT=<<EOF
|
|
0x00000000 [^__________________________________________] 0x00000200
|
|
EOF
|
|
RUN
|
|
|
|
NAME=p- bounds
|
|
FILE=malloc://0x1000
|
|
CMDS=<<EOF
|
|
e hex.cols=0
|
|
f test @ 0x1000
|
|
p- 0x40 # 0x1000 % 0x40 = 0
|
|
p- 0xa # 0x1000 % 0xa != 0
|
|
f- test
|
|
f test @ 0xfff
|
|
p- 0x40 # 0x1000 % 0x40 = 0
|
|
p- 0xa # 0x1000 % 0xa != 0
|
|
EOF
|
|
EXPECT=<<EOF
|
|
0x00000000 [^_______________________________________________________________] 0x00001000
|
|
0x00000000 [^_________] 0x00001000
|
|
0x00000000 [^______________________________________________________________.] 0x00001000
|
|
0x00000000 [^________.] 0x00001000
|
|
EOF
|
|
RUN
|
|
|
|
NAME=p-j
|
|
FILE=malloc://0x1000
|
|
CMDS=<<EOF
|
|
e hex.cols=0
|
|
f test @ 0x1000
|
|
p-j 0x4~{} # 0x1000 % 0x4 = 0
|
|
echo -------
|
|
p-j 0xa~{} # 0x1000 % 0xa != 0
|
|
echo -------
|
|
f- test
|
|
f test @ 0xfff
|
|
af+ hello @ 0x3ff
|
|
afb+ 0x3ff 0x3ff 0x10
|
|
p-j 0x4~{} # 0x1000 % 0x40 = 0
|
|
echo -------
|
|
p-j 0xa~{} # 0x1000 % 0xa != 0
|
|
EOF
|
|
EXPECT=<<EOF
|
|
{
|
|
"from": 0,
|
|
"to": 4096,
|
|
"blocksize": 1024,
|
|
"blocks": [
|
|
{
|
|
"offset": 0,
|
|
"size": 1024,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 1024,
|
|
"size": 1024,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2048,
|
|
"size": 1024,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 3072,
|
|
"size": 1024,
|
|
"perm": "rwx"
|
|
}
|
|
]
|
|
}
|
|
-------
|
|
{
|
|
"from": 0,
|
|
"to": 4096,
|
|
"blocksize": 410,
|
|
"blocks": [
|
|
{
|
|
"offset": 0,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 410,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 820,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 1230,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 1640,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2050,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2460,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2870,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 3280,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 3690,
|
|
"size": 406,
|
|
"perm": "rwx"
|
|
}
|
|
]
|
|
}
|
|
-------
|
|
{
|
|
"from": 0,
|
|
"to": 4096,
|
|
"blocksize": 1024,
|
|
"blocks": [
|
|
{
|
|
"offset": 0,
|
|
"size": 1024,
|
|
"flags": 1,
|
|
"functions": 1,
|
|
"in_functions": 1,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 1024,
|
|
"size": 1024,
|
|
"in_functions": 1,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2048,
|
|
"size": 1024,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 3072,
|
|
"size": 1024,
|
|
"flags": 1,
|
|
"perm": "rwx"
|
|
}
|
|
]
|
|
}
|
|
-------
|
|
{
|
|
"from": 0,
|
|
"to": 4096,
|
|
"blocksize": 410,
|
|
"blocks": [
|
|
{
|
|
"offset": 0,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 410,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 820,
|
|
"size": 410,
|
|
"flags": 1,
|
|
"functions": 1,
|
|
"in_functions": 1,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 1230,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 1640,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2050,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2460,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 2870,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 3280,
|
|
"size": 410,
|
|
"perm": "rwx"
|
|
},
|
|
{
|
|
"offset": 3690,
|
|
"size": 406,
|
|
"flags": 1,
|
|
"perm": "rwx"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
RUN
|