Re: Help: build failure due to relocation truncated to fit: R_MIPS_GOT16 and others

James Cowgill <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <[email protected]>
On 20/11/16 16:47, Steve M. Robbins wrote:
> Hi,
> 
> I'd appreciate some help solving a MIPS-only build failure in googletest.  It 
> fails for arch mips [1], mipsel, and mips64el.  A sample of the error output:
> 
>     relocation truncated to fit: R_MIPS_GOT16 against 
> `__stack_chk_guard@@GLIBC_2.4'
>     relocation truncated to fit: R_MIPS_CALL16 against `operator new(unsigned 
> int)@@GLIBCXX_3.4'
> 
> [ and many similar]
> 
> I'm kind of googling blind here .   I've found a smattering of similar 
> questions with answers that point to using '-Gn' or '-mxgot'.  But I haven't a 
> solid grounding to understand what the implications are.  

These relocation errors mean you have too many symbols in the GOT in
your executable. MIPS usually uses a single instruction to access the
GOT, but that only works for small GOTs. If your GOT is too large, it's
still possible to make it work using -mxgot, but it takes 3 instructions
to load a 32-bit address, add to the gp register, and do the final load.
Since you don't know how the linker will allocate the GOT, you have to
use -mxgot on all C/C++ files. The penalty occurs when you access any
non-static global functions/variables.

Your options are: reduce the number of symbols which span across
translation unit boundaries (thus reducing the size of the GOT), or
compile with -mxgot on MIPS with a slight speed penalty.

James
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE+Ixt5DaZ6POztUwQx/FnbeotAe8FAlgx8/gACgkQx/Fnbeot
Ae+uag/+ItM5uWSYuwKwqmTH+9ogDcP3wVqE8TEOz+wbu/Ah309nv2qqZ3QZmm7q
kraGKEEoEo5acGDkj244OhO90hegRcTYTlqVXae5tqqSSVxxHH6zxQL8ydFgXP6n
nEp+wLSab2AV37yq7uyvnD5vpnO5iYyLdR5nwxMSlp2lGep5xO23Sez12HrNV6tt
kue9A3x66bVuym7N01OaqnXvqj6elR1CNt4vS/OVsAyTH3vRhfxERsHMmbaEqo0i
r9ETV5T2hzWdtoGKy135AE5cv9tv3TW8LPU4NXeYgq7mo2eMDAgJ8ZZUDYSXXec+
KOmqcls3osxRz1EZYHj/F4jfMvU/uKu7CgPrpL0FbNf+05F642DjMOnRIpZIUVgl
88CU0L725LoCGJfPIXK+52rgVe3M1fWcIzhhoFrIImq/qdys4YaSswpIlOWDhuxg
bMGNO/+z59W7t9a7oS467TGBkEagu/uKPf03GpjMDJw1AgrBIof8c3XKECzYq3CT
Dag/Zl3hxkveoA2p4xruD/810gEH6zGo4l0lT7kyn/w4Rbch6zvvh5HHZGxJ5Csz
NrZOhG8VCjBUAIGpF1AKUnU4gmjONZ5+m3/JMaqzoEZ3MPWOuJiOSK6cHVF7jqDe
OVbE0zi/RwM5r/wgjd+y9m8SK82ipWvrLwm5VWm40HSfyogPXvI=
=5cPW
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.