From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shinya Kuribayashi Date: Wed, 17 Oct 2007 23:27:40 +0900 Subject: [U-Boot-Users] _gp in current u-boot.lds for MIPS ports In-Reply-To: References: <47123C81.6050902@ruby.dti.ne.jp> <20071016181916.3E20F242E9@gemini.denx.de> Message-ID: <47161BDC.2030006@ruby.dti.ne.jp> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Andrew, Andrew Dyer wrote: > Typically _gp is set in the linker script to 0x7ff0 above the start of > the 'small' sections (all ELF sections with SHF_MIPS_GPREL flag), so > that all small items can be accessed by a 16 bit signed offset off of > the register allocated for _gp. The 16-bit signed offset corresponds > to the native MIPS addressing mode. The .got section usually comes > first in the link map and so .got + 0x7ff0 = _gp. > > Somewhere in the linking process the linker calculates the signed > offset necessary for each instruction accessing data in these sections > based on the _gp symbol from the link scripts and puts that into the > appropriate offset field in the instruction. > > For us, I don't believe it matters where _gp is, as long as the > relative offsets to all small items can be held in the 16 bit field > and that _gp is aligned properly. Obviously we need to fixup the _gp > register correctly during relocation. Since _gp is only a pointer, > IMHO it makes sense to adhere to the standard map with a 0x7ff0 > offset. > > (BTW, ${CROSS_COMPILE}ld --verbose will dump the normal link script > that gets used in an ELDK setup) Good abstract. I hope that I don't miss anything. I'll submit patches later, please review them. thanks a lot, Shinya