Open H-A-M-G-E-R opened 10 hours ago
This is most likely a bug in whatever compiler spec you are using, or you are using the wrong compiler spec.
If the function doesn't return a value, then change the type of return to "void". Ghidra makes guesses at function signatures, it doesn't always get them right and it is the user's job to fix the signatures and then commit them.
The compiler that's commonly used in GBA games is agbcc: https://github.com/pret/agbcc, and the code provided above is what agbcc generates, so it's Ghidra's bug, not agbcc's bug. bx r0
returns void while bx r1
returns the value in r0
.
When Ghidra 11.2.1 decompiles a function to:
while the assembly looks like this:
the expected behavior should look like this: