-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Although I know this is integrated in Ghidra now, only collaborators can submit issues there, and since the implementation is based on your code @yath, I thought you might know how to solve this bug.
When patching an instruction to movi.n
, an "invalid instruction and/or prefix" error is caused.
To Reproduce
Steps to reproduce the behavior:
- Open an ESP32 firmware image
- Go to a two-byte instruction
- Right click -> Patch instruction (or Ctrl+Shift+G)
- Enter
movi.n a2,0x0
- While typing, the instruction/parameters are even suggested for auto-completion, but entering the full instruction yields an "invalid instruction and or prefix" error. It seems the error originates from Ghidra's AssemblyDualTextField.java#924, where the following error is generated:
Could not solve two-sided OR (Solution to tmp : 761 in 0 = (((([opval:n_s3_4_6 exp [ins(4,6), bytes 0-0, shift=4]] & 0x7) << 0x4) | ([opval:n_s4_12_15 exp [ins(12,15), signed, bytes 1-1, shift=4]] & 0xf)) | (((([opval:n_s3_4_6 exp [ins(4,6), bytes 0-0, shift=4]] >> 0x2) & 0x1) & (([opval:n_s3_4_6 exp [ins(4,6), bytes 0-0, shift=4]] >> 0x1) & 0x1)) << 0x7)))
My suspicion is that this has to do with the definition of the movi.n instruction in xtensaInstructions.sinc, but I don't know how to fix it, and AI isn't being of much help either...
Expected behavior
Ghidra finds the instruction and updates the bytecode with the correct bytes (0c 02
in case of movi.n a2,0x0
).
Metadata
Metadata
Assignees
Labels
No labels