
On Fri, 25 Jul 2008 22:51:09 +0200 kenneth johansson kenneth@southpole.se wrote:
Hmm...looks like linking with -pie (or --pic-executable) does something vaguely resembling the trick. But I don't know what vintage of ld you need for this to be available and actually work...
Can't see any reason for using this flag over -fPIC for a program like u-boot.
You need both. One is a compiler flag, the other is a linker flag. The linker will probably barf if you try to create a PIC executable from modules that were not compiled with -fPIC.
On the other hand, using -fPIC but not -pie takes us about 95% of the way to a fully relocatable u-boot, and is what PowerPC, AVR32 and others are doing today. The remaining cases -- static and global initialized pointers -- are fixed up manually.
If we link with -pie and add a bit of code to handle the dynamic relocations, we could get rid of the manual fixups. I don't know if the result would be larger or smaller than what we have today, but it would probably be a bit more robust.
Does this really work without any relocation? Or is it being relocated and I'm just too blind to see it?
No you are right there is probably many places like this. the code just use the old location and that works most of the time.
Ah, of course. The strings are probably read directly from flash.
Haavard