5

I've been using Ghidra to decompile some .o library files originally compiled for ARMv7, for which I have header files for some of the functions and structs.

Let's say a struct has several single-byte "char" members:

struct myStruct {
   char memberA;
   char memberB;
   char memberC;
   char memberD;
} structInstance;

Where the assembly code, presumably by way of compiler optimization when it was built, is cutting a corner and accessing a whole 32-bit word's worth of the chars in one go, then the decompiled C code will represent this as:

structInstance._0_4_

The first digit (0) being the offset of the byte to start from, and the second digit (4) being the number of bytes being accessed.

However, from what I can tell, this is non-standard and won't recompile - at least not in GCC, and I can't really find any reference to this notation anywhere.

Is there any way Ghidra can be set to instead generate decompiled code which would in fact be valid - i.e.

*(uint32_t)&structInstance.memberA
beammy
  • 161
  • 4
  • 2
    I'm not sure if Ghidra's de-compiler has any guarantees that it will produce something that can be compiled. It produces some C-like code to help you analyze but not sure if it should be something you can just take and compile. – Paweł Łukasik Apr 22 '20 at 10:00

0 Answers0