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

Track instruction packet membership in more detail #18

Closed
Rot127 opened this issue Aug 17, 2021 · 1 comment · Fixed by #16 or rizinorg/rizin#1614
Closed

Track instruction packet membership in more detail #18

Rot127 opened this issue Aug 17, 2021 · 1 comment · Fixed by #16 or rizinorg/rizin#1614
Labels
bug Something isn't working

Comments

@Rot127
Copy link
Member

Rot127 commented Aug 17, 2021

Hexagon instructions can belong to instruction packets. To mark those packet the assembly gets prefixed (with /,\,|) like that:

; two instruction packets.
/ immext(##0x1c00)
| R11 = ##loc.start_pc
| immext(##0x1c00)
\ R12 = ##loc.start_sp
/ R15 = asl(R15,R2)
\ memw(R13+R2<<#0x2) = R5

Here is how the plugin assigns the correct packet prefix to the assembly:

  • The last instruction in a packet has certain bits set. (See reference manual v67 Chapter 10.5).
    • Prefix it with \, set new_pkt_starts = true
  • A new packet starts (because the previous instruction was the last instruction in its packet.)
    • The next instruction is prefixed with a /
  • Each following instruction is prefixed wit a |, if it is not the last instr. nor the first one.

The logic is implemented in hex_set_pkt_info().

Unfortunately this causes some problems.
Assume the correctly disassembled instruction packet:

> s 0x00005170
> pi 4
0x00005170      /     immext(##0x1c00)    ;  #1 in packet
0x00005174      |     R11 = ##loc.start_  ;  #2 in packet
0x00005178      |     immext(##0x1c00)    ;  #3 in packet
0x0000517c      \     R12 = ##loc.start_  ;  #4 in packet

now do:

> s 0x00005174
> pi 1
/     R11 = ##loc.start_  // Is marked as #1, but is #2 in packet

Bug: R11 = ##loc.start_ should be prefixed with a | but has a / because the last disassembled instruction (R12 = ##loc.start_ at 0x0000517c) was marked as the last packet in the packet.

To solve this the plugin somehow needs to peek into the previous instruction in memory. This way it could check, whether it is indeed the first one.

@Rot127 Rot127 added the bug Something isn't working label Aug 17, 2021
@Rot127 Rot127 changed the title Track instr. packet memebership in more detail Track instruction packet membership in more detail Aug 17, 2021
@Rot127
Copy link
Member Author

Rot127 commented Aug 17, 2021

Also consider #17 when fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant