Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve valid names for symbols and sections #400

Closed
XVilka opened this issue Jan 20, 2021 · 3 comments · Fixed by #798
Closed

Preserve valid names for symbols and sections #400

XVilka opened this issue Jan 20, 2021 · 3 comments · Fixed by #798
Milestone

Comments

@XVilka
Copy link
Member

XVilka commented Jan 20, 2021

Questions Answers
OS/arch/bits (mandatory) -
File format of the file you reverse (mandatory) ELF
Architecture/bits of the file (mandatory) ARM
rizin -v full output, not truncated (mandatory) rizin 0.1.0-git 26825 @ linux-x86-64 git.4.5.1-859-gd17c2574d
commit: d17c257 build: 2021-01-20__13:20:57

Expected behavior

See the readelf output, for example:

[i] ℤ readelf -SW 006.make.elf.arm32                                                                                                                                                                                              15:16:08 
There are 28 section headers, starting at offset 0x2caa0:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00010154 000154 000019 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            00010170 000170 000020 00   A  0   0  4
  [ 3] .note.gnu.build-id NOTE            00010190 000190 000024 00   A  0   0  4
  [ 4] .gnu.hash         GNU_HASH        000101b4 0001b4 000cbc 04   A  5   0  4
  [ 5] .dynsym           DYNSYM          00010e70 000e70 001a80 10   A  6   1  4
  [ 6] .dynstr           STRTAB          000128f0 0028f0 0015b6 00   A  0   0  1
  [ 7] .gnu.version      VERSYM          00013ea6 003ea6 000350 02   A  5   0  2
  [ 8] .gnu.version_r    VERNEED         000141f8 0041f8 000090 00   A  6   3  4
  [ 9] .rel.dyn          REL             00014288 004288 000048 08   A  5   0  4
  [10] .rel.plt          REL             000142d0 0042d0 0003e8 08  AI  5  22  4
  [11] .init             PROGBITS        000146b8 0046b8 00000c 00  AX  0   0  4
  [12] .plt              PROGBITS        000146c4 0046c4 0005f0 04  AX  0   0  4
  [13] .text             PROGBITS        00014cb8 004cb8 021060 00  AX  0   0  8
  [14] .fini             PROGBITS        00035d18 025d18 000008 00  AX  0   0  4
  [15] .rodata           PROGBITS        00035d20 025d20 0058d8 00   A  0   0  4
  [16] .ARM.exidx        ARM_EXIDX       0003b5f8 02b5f8 000008 00  AL 13   0  4
  [17] .eh_frame         PROGBITS        0003b600 02b600 000004 00   A  0   0  4
  [18] .init_array       INIT_ARRAY      0004bef8 02bef8 000004 04  WA  0   0  4
  [19] .fini_array       FINI_ARRAY      0004befc 02befc 000004 04  WA  0   0  4
  [20] .data.rel.ro      PROGBITS        0004bf00 02bf00 000004 00  WA  0   0  8
  [21] .dynamic          DYNAMIC         0004bf04 02bf04 0000f8 08  WA  6   0  4
  [22] .got              PROGBITS        0004c000 02c000 000204 04  WA  0   0  4
  [23] .data             PROGBITS        0004c208 02c208 00072c 00  WA  0   0  8
  [24] .bss              NOBITS          0004c938 02c934 002dd8 00  WA  0   0  8
  [25] .ARM.attributes   ARM_ATTRIBUTES  00000000 02c934 00002f 00      0   0  1
  [26] .gnu_debuglink    PROGBITS        00000000 02c964 000034 00      0   0  4
  [27] .shstrtab         STRTAB          00000000 02c998 000108 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  y (purecode), p (processor specific)

Actual behavior

It substitutes characters like - in the section name: .note.gnu.build_id is in fact should be note.gnu.build-id, .note.ABI_tag should be .note.ABI-tag:

[i] ℤ rizin 006.make.elf.arm32                                                                                                                                                                                                    
[0x00016d10]> iS
[Sections]

nth paddr          size vaddr         vsize perm name
―――――――――――――――――――――――――――――――――――――――――――――――――――――
0   0x00000000      0x0 0x00000000      0x0 ---- 
1   0x00000154     0x19 0x00010154     0x19 -r-- .interp
2   0x00000170     0x20 0x00010170     0x20 -r-- .note.ABI_tag
3   0x00000190     0x24 0x00010190     0x24 -r-- .note.gnu.build_id
4   0x000001b4    0xcbc 0x000101b4    0xcbc -r-- .gnu.hash
5   0x00000e70   0x1a80 0x00010e70   0x1a80 -r-- .dynsym
6   0x000028f0   0x15b6 0x000128f0   0x15b6 -r-- .dynstr
7   0x00003ea6    0x350 0x00013ea6    0x350 -r-- .gnu.version
8   0x000041f8     0x90 0x000141f8     0x90 -r-- .gnu.version_r
9   0x00004288     0x48 0x00014288     0x48 -r-- .rel.dyn
10  0x000042d0    0x3e8 0x000142d0    0x3e8 -r-- .rel.plt
11  0x000046b8      0xc 0x000146b8      0xc -r-x .init
12  0x000046c4    0x5f0 0x000146c4    0x5f0 -r-x .plt
13  0x00004cb8  0x21060 0x00014cb8  0x21060 -r-x .text
14  0x00025d18      0x8 0x00035d18      0x8 -r-x .fini
15  0x00025d20   0x58d8 0x00035d20   0x58d8 -r-- .rodata
16  0x0002b5f8      0x8 0x0003b5f8      0x8 -r-- .ARM.exidx
17  0x0002b600      0x4 0x0003b600      0x4 -r-- .eh_frame
18  0x0002bef8      0x4 0x0004bef8      0x4 -rw- .init_array
19  0x0002befc      0x4 0x0004befc      0x4 -rw- .fini_array
20  0x0002bf00      0x4 0x0004bf00      0x4 -rw- .data.rel.ro
21  0x0002bf04     0xf8 0x0004bf04     0xf8 -rw- .dynamic
22  0x0002c000    0x204 0x0004c000    0x204 -rw- .got
23  0x0002c208    0x72c 0x0004c208    0x72c -rw- .data
24  0x0002c934      0x0 0x0004c938   0x2dd8 -rw- .bss
25  0x0002c934     0x2f 0x00000000     0x2f ---- .ARM.attributes
26  0x0002c964     0x34 0x00000000     0x34 ---- .gnu_debuglink
27  0x0002c998    0x108 0x00000000    0x108 ---- .shstrtab

Steps to reproduce the behavior

$ rizin 006.make.elf.arm32
[0x00016d10]> iS

See implementation in:

  • librz/bin/formats/elf
  • librz/bin/p/bin_elf.c

Additional Logs, screenshots, source-code, configuration dump, ...

006.make.elf.arm32.zip

@XVilka XVilka added this to the 0.2.0 milestone Jan 20, 2021
@XVilka XVilka modified the milestones: 0.2.0, 0.3.0 Mar 1, 2021
@XVilka XVilka added the RSoC label Mar 5, 2021
@fangxlmr
Copy link
Contributor

fangxlmr commented Mar 9, 2021

@Yuuoniy This issue is asigned to you as RSoC micro-task, so you could work on this from now on. Feel free to ask questions and send Pull Requests.

In case for anyone who is not aware about RSoC.

CC @XVilka

@Yuuoniy
Copy link
Contributor

Yuuoniy commented Mar 9, 2021

Got it.

@Yuuoniy
Copy link
Contributor

Yuuoniy commented Mar 9, 2021

I‘ve made a PR for this #798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants