So the way the plugin loader/linker code currently works (on PS2, psp, Dreamcast) is this:
- We build a main ELF with an absolute position in memory.
- We use a custom ld linker script to link together relocatable plugins. Since the main ELF has absolute addresses, some of the more complicated jumps (like those from plugin code back to the main ELF) can be resolved during this pre-linking without the need for us to write explicit loader code for them.
- Our loader code shifts the location of a plugin in memory and adjusts relocations within the plugin.
Doing things this way (with a non-relocatable main executable and a custom ld linker script for plugins) saves us much of the more extensive and complicated work (such as maintaining a Global Offset Table).
Over the past couple of days, I’ve come to understand (though I’m not 100% sure) that the Wiz is unlike most “smaller targets” in that its launcher requires Position-Independent-Code. This poses quite a big problem seeing as the way we’re doing things depends on the main executable having absolute addresses that the ld script can use. To implement the custom ELF loader/linker on the Wiz, then, will likely be quite an extensive task.
Since (in my proposal) I intended the Wiz to be a testbed for a more crucial target (the DS), I’ve talked with my mentor about moving on to other work towards supporting the DS and ditching the Wiz (at least, for now).
A good first step in this respect would be starting work on changing the plugin system to support only loading one plugin at a time. Some discussion has gone on as to how to achieve this and I’ve posted my current (under construction :-)) plans for it on my wiki at http://wiki.scummvm.org/index.php/User:Toneman. I’ll be discussing things further with my mentor and posting schedule changes there as well (I’m not absolutely sure about whether Wiz work will continue), but for today I’m going to start looking into the DS port (possibly writing a custom linker for it and seeing what ARM relocation types I need to worry about for it).