Open tomsons26 opened 5 years ago
I don't think I'll be supporting ELF formatted binaries in this loader. I looked into doing it, but it seems like my choices are either to use the stock ELF loader Ghidra supplies or create a completely new one. If anyone else wants to implement it, then by all means go for it.
I would like to second the request for elf support. The stock Ghidra ELF loader does not seem to properly handle Gamecube elf files properly. It seemingly fails to decode the instructions in many functions, and creates unusable results. This is a shame because the game I'm working on has full debug symbol coverage in this elf and I have no way of utilizing it, since I can't actually load the elf in anything.
I've imported a few ELF files from Wii games without issue; the one thing you need to do when using the default ELF loader is change the language from normal powerpc to the gekko variant (otherwise, you will get unknown instructions). (I don't remember if you need to uncheck the show only recommended languages option for gekko to show up in that case).
Oh, though I should add that importing like that does skip the other functionality provided by this (detecting SDA values and generating the default sections). For the first one I use a script to set up the SDA, and for the second I can use the following python:
from ghidra.app.util.importer import MessageLog
from gamecubeloader.common import SystemMemorySections
log = MessageLog()
SystemMemorySections.Create(currentProgram, log)
log.write(None, None)
For more recent versions, I was able to do this as a workaround instead:
from ghidra.app.util.importer import MessageLog
from gamecubeloader.common import SystemMemorySections
from ghidra.app.util.bin import ByteProvider
from ghidra.util.task import TaskMonitor
log = MessageLog()
SystemMemorySections.Create(ByteProvider.EMPTY_BYTEPROVIDER, currentProgram, TaskMonitor.DUMMY, log)
log.write(None, None)
The SDA portion is available as an analyzer (the GameCube/Wii program analyzer, which isn't checked by default).
In some games the unstripped ELF has been left in, currently trying to load these it throws "Unable to load REL file! Reason: Relocation Data offset in header is past the file bounds!"
Also worth noting there's typically a .debug section in these ELF's containing partial?(seems to be the devs selected what to include as symbols for specialized debugging) debug symbols. ELF's like these can be found though-ought the GC SDK.