From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haavard Skinnemoen Date: Sat, 26 Jul 2008 17:54:54 +0200 Subject: [U-Boot-Users] Changing u-boot relocation scheme In-Reply-To: <1217019069.7972.58.camel@duo> References: <20080724185734.6d79c419@hskinnemo-gx745.norway.atmel.com> <20080725042816.4F8B1248A5@gemini.denx.de> <20080725111041.4c0b925a@siona.local> <1216986958.17719.13.camel@duo> <20080725141909.4a635af0@siona.local> <1216996436.7972.14.camel@duo> <20080725172334.13ee6301@siona.local> <1217003489.7972.33.camel@duo> <488A0729.1070306@ge.com> <1217006928.7972.47.camel@duo> <20080725203517.2b940103@siona.local> <1217019069.7972.58.camel@duo> Message-ID: <20080726175454.17a14a97@siona.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, 25 Jul 2008 22:51:09 +0200 kenneth johansson 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