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>
22 lines
1,014 B
Text
22 lines
1,014 B
Text
NAME=t/utf32
|
|
FILE=bins/elf/crackme0x00b
|
|
CMDS=iz
|
|
EXPECT=<<EOF
|
|
paddr vaddr len size section type string
|
|
-----------------------------------------------------------------
|
|
0x0000024d 0x0804824d 14 15 .dynstr ascii __gmon_start__
|
|
0x0000025c 0x0804825c 9 10 .dynstr ascii libc.so.6
|
|
0x00000266 0x08048266 14 15 .dynstr ascii _IO_stdin_used
|
|
0x00000275 0x08048275 14 15 .dynstr ascii __isoc99_scanf
|
|
0x00000284 0x08048284 4 5 .dynstr ascii puts
|
|
0x00000289 0x08048289 6 7 .dynstr ascii printf
|
|
0x00000290 0x08048290 6 7 .dynstr ascii wcscmp
|
|
0x00000297 0x08048297 17 18 .dynstr ascii __libc_start_main
|
|
0x000002a9 0x080482a9 9 10 .dynstr ascii GLIBC_2.7
|
|
0x000002b3 0x080482b3 9 10 .dynstr ascii GLIBC_2.0
|
|
0x000005d0 0x080485d0 16 17 .rodata ascii Enter password:
|
|
0x000005e5 0x080485e5 9 10 .rodata ascii Congrats!
|
|
0x000005ef 0x080485ef 6 7 .rodata ascii Wrong!
|
|
0x00001040 0x0804a040 8 36 .data utf32le w0wgreat
|
|
EOF
|
|
RUN
|