On Wed, 2013-01-02 at 15:33 +0100, Alexander Graf wrote:
I'd be inclined to say it's the latter. But we should ask Ben to make sure.
Ben, is the firmware mapped r/w on Macs?
Of course not :-)
If it's the latter, I think there is going to have to be a fairly
major patch to remove static variables completely from the target image codebase.
No it's easy to fix
Can't we manually relocate our OpenBIOS code when relocating it?
Imagine we add an extra extraction step to the build process before omitting the final .elf file. In that step we copy the elf relocation info into a special data section that is accessible from within OpenBIOS.
Now when we relocate our .text section down to offset 0x0 we also run a normal elf relocator to move all .data variable access down to offset 0x0.
That way we could still keep globals around, right?
Just relocate .data, that's trivial.
Use the .lds to specify a different load address from link address, put the link address in memory along with the bss and in your early startup code, copy them from the load address to the link address.
No need to process ELF relocs or anything like that.
I'm sure you can find examples of how to do that all over the place (uboot would be a place to look if you don't know the .lds syntax for this, off the top of my head you look for the AT() directive).
Cheers, Ben.