Replies: 5 comments
-
I think you either have to mark the entire region as volatile in the memory map (Windows > Memory Map), or untick "Eliminate unreachable code" (Right click in the decompiler text > Properties > Decompiler > Analysis). I think you can also change whatever type INT_STATUS is, to volatile. |
Beta Was this translation helpful? Give feedback.
-
Marking all memory regions as volatile doesn't change the output at all; unticking "Eliminate unreachable code" does make it a little better, but it still generates loops that look like |
Beta Was this translation helpful? Give feedback.
-
I can confirm that "Eliminate unreachable code" had no effect. Similarly, marking the entire region as volatile hamstrings the decompiler. Ideally, volatile could be included as part of the type. |
Beta Was this translation helpful? Give feedback.
-
This problem is common in embedded applications (ie non-os) like on the AVR and ARM Cortex M architecture. An example which occurs frequently is something like:
|
Beta Was this translation helpful? Give feedback.
-
Found a similar condition in PSX code (MIPS processor):
The decompiled code is:
Where I believe the code should be more along the lines of:
I've got the whole block ("hardware_registers" 1f801000-1f802fff) set to volatile. |
Beta Was this translation helpful? Give feedback.
-
I have a function which, simplified, is as follows:
However, Ghidra doesn't know that
INT_STATUS
can change externally and instead decompiles it to an infinite loop (and kills everything after it). Is there a way to mark a structure field as volatile so that the reads don't get optimized away?Beta Was this translation helpful? Give feedback.
All reactions