NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
52.13k stars 5.91k forks source link

[68000] Trap instruction order bug #1525

Open lab313ru opened 4 years ago

lab313ru commented 4 years ago

Decompiler has a bug related to order of instructions if trap instruction used.

изображение

Decompiler shows me the following:

изображение

As you can see here, order of instructions is wrong.

astrelsky commented 4 years ago

This may not just be the 68000. I saw something similar in arm yesterday. Not with trap, just instruction ordering in general didn't make sense.

lab313ru commented 4 years ago

Seems, that happens, because trap instruction is not an instruction.:)

Here, I tried to change instruction flow via Modify instruction flow...:

изображение

simeonpilgrim commented 4 years ago

from 68000.sinc: line 1685 :trap "#"^op03 is opbig=0x4e & op67=1 & op45=0 & op03 { vector:1 = op03; __m68k_trap(vector); } trap is just a "string output line", which is not altering/using any prior lines, thus might be seen has having no positional dependency. Would be interesting to know if that a bug in the decompiler allow pcodeop's to be rearranged, or something missing from the constructor of the instruction.