TOC/OPD/GOT/etc. is not processed in ELFs using PPC64 with 32-bit addressing
See original GitHub issueDescribe the bug Take any ELF64 file using PowerPC64 and 32-bit addressing. I was using “PowerISA-Altivec-64-32addr”, but any PPC64 language with 32-bit addressing will suffice.
This is handled by `PowerPC64_ElfExtension". It satisfies this check:
However when processElf
is called then this check is included:
Which fails since it is equal to 32.
This may just be an unimplemented feature (I would need to see what assumptions the class makes), but we can clearly see that files imported using this PPC variation are not properly processed.
To Reproduce Steps to reproduce the behavior:
- Take any ELF file satisfying the aforementioned description. I used a PS3 EBOOT file.
- Analyse this file.
- Note how the
TOC_BASE
symbol is never created and howr2
is not set at all in any function.
Environment (please complete the following information):
- OS: Windows 10 Education 1809
- Java Version: 12
- Ghidra Version: 9.0.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
64-bit PowerPC ELF Application Binary Interface Supplement ...
Functions called during signal handling have no unusual restrictions on their use of registers. Moreover, if a signal handling function returns, the process...
Read more >Can PowerPC64 ELF file have 32-bit pointers?
I've been given an ELF binary file which self describes as PowerPC 64-bit. The e_entry field of the ELF header points to the...
Read more >Programming Environments Manual for 32-Bit ... - NXP
not designed, intended, or authorized for use as components in systems ... Programming Environments Manual for 32-Bit Implementations of the PowerPC ...
Read more >PowerPC Processor Supplement - Linux Foundation
How to Use the PowerPC Processor ABI Supplement ... No Padding—Little-Endian ... Conceptually, processes have the full 32-bit address space available to ...
Read more >32-bit absolute addresses no longer allowed in x86-64 Linux?
Older versions of gcc use 32-bit absolute addresses for static arrays in order to save an extra instruction for relative address calculation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update: @aerosoul94 discovered that if
r2
is added to the<unaffected>
list here: https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Processors/PowerPC/data/languages/ppc_64_32.cspec#L96 then the decompiler issue with it is fixed. Here’s a comparison:Left is before the fix, right is after. Look specifically at the TOC-relative string references that are resolved after the fix. (right is also on 9.2, but it doesn’t matter, 9.1.2 is fixed with this too)
Let me know if you need anything else.
I’ve made bold what is most relevant to this issue but here are PS3 (PPU) ABI changes for reference:
Relocations are handled differently as well (note the use of patchseg and symseg): https://github.com/aerosoul94/ida_gel/blob/master/src/ps3/cell_loader.cpp#L334
OPD section recovery is likely necessary because they strip sections (or maybe just section names actually) for retail binaries.
@Bo98 A workaround would be taking the TOC from the function descriptor, then setting the r2 register value for that function.