-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PowerPC] Ghidra decompiler doesn't understand non-r2 SDA #325
Comments
Some PowerPC code I've seen even uses r2,r13,r14,r15,r16 (GM E98 ECU; not sure which compiler this is). |
Just looking at the screenshot, it looks like r13 may be getting treated as a save register, which I think is a non-standard ABI. You could try adding r13 to the unaffected list in the cspec to see if this helps decompilation. Its hard to tell from the screenshot, but I'm assuming you're using ppc_32_be.cspec. Look for the lines:
Add a " line, then save and restart. You also might want to investigate turning on in-lining or applying a call-fixup for the _savegpr_26 function. It looks suspiciously like an internal compiler function. |
@caheckman yeah,
|
@caheckman it works, papa bless |
I came across this a few days ago: https://github.com/aldelaro5/ghidra-gekko-broadway-lang Would you mind creating a pull request which the guy maintaining this plugin could add there in order to make decompilation of the Broadway / Gekko stuff even better? I mean also this stuff you described here. I came across this as well upon decompilation of the debugger kernel which was a royal pain in the a**... Thanks in advance. |
It's already been fixed 20 days ago: aldelaro5/ghidra-gekko-broadway-lang@d4a57a6 |
Am I doing something wrong? It still doesn't seem to recognize labels relative to r13. |
I'm also still having the same issue as you. |
Did you actually set r2/r13? @derek57 @RenaKunisaki |
I did get it, but I'm really not sure how. It felt like it just decided to work. |
Well, I finally got it done - thx to @NWPlayer123. Isn't it possible to directly implement this into @aldelaro5's Ghidra Gekko repo at https://github.com/aldelaro5/ghidra-gekko-broadway-lang/ ? |
Context: GameCube and Wii are compiled with two Small Data Area/Table Of Contents (SDA/TOC) registers, that it reserves for single-instruction data manipulation, r2 and r13. Right now it looks like it only understands r2.
Whenever it hits r13, it sets a variable and then manually shows the (r13 - 0x____) as a variable, instead of knowing that there's a variable there, which gives really terrible decompilation results.
The text was updated successfully, but these errors were encountered: