[committed] correct nios2 _gp address computation

Sandra Loosemore sandra@codesourcery.com
Sun Dec 27 20:45:00 GMT 2015


A month or two ago, I noticed that building a complete nios2-linux-gnu 
toolchain from mainline sources was dying with GP-relative relocation 
overflows in the linker.  At first I thought this might have been caused 
by an explosion in the size of the GOT (which the linker script locates 
at the lower end of the small data area), but on further investigation 
it turned out that the value of _gp used internally to determine offsets 
for the relocations was being calculated incorrectly.  The code has been 
like that forever and I'm still rubbing my eyes that we didn't spot this 
error long before now.  :-(

Comparing this to MIPS and other targets that support GP-relative 
addressing, I noticed that the equivalent of nios2_elf_assign_gp in 
those backends does something completely different, but I couldn't get 
that to work on nios2-linux-gnu (it kept complaining about _gp being 
undefined instead of finding the definition in the linker script).  So, 
I went with the most obvious fix to the existing code.  I also checked 
in some cleanup of the error message formatting code that I hacked up 
while tracking this down.

-Sandra

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nios2-gp.log
Type: text/x-log
Size: 219 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20151227/8e08f768/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nios2-gp.patch
Type: text/x-patch
Size: 2750 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20151227/8e08f768/attachment-0001.bin>


More information about the Binutils mailing list