[U-Boot-Users] _gp in current u-boot.lds for MIPS ports

Shinya Kuribayashi skuribay at ruby.dti.ne.jp
Wed Oct 17 16:27:40 CEST 2007


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






More information about the U-Boot mailing list