Suppose we have the following C source:
typedef struct {
int bit0 : 1;
int bit1 : 1;
int bit2 : 1;
int bit3 : 1;
} bit_struct;
bit_struct a;
void setBit3()
{
a.bit3 = 1;
}
When we compile it and open the result in Ghidra, the decompilation window shows
void setBit3(void)
{
a = a | 8;
return;
}
If we give Ghidra the declaration of bit_struct
(using File
-> Parse C Source
), and then go to the location of a
and set its data type to bit_struct
, the decompilation changes to
a = (bit_struct)((byte)a | 8);
which still doesn't access bit3
by declared name.
How can we make Ghidra properly decompile it?