[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Use -mxgot to fix relocation errors on mips?



Mike Furr wrote:
[snip]
> One of my packages failed to build[0] on mips due to a bunch of linking
> errors like:
> ~  relocation truncated to fit: R_MIPS_GOT16 <symbol>
> 
> Reading through -mips and -gcc archives I see this problem has surfaced
> for packages like mozilla and gcj.  The general fix seems to be adding
> - -mxgot to the build flags, but some of the posts suggested that this is
> not always a good idea.

In short: Use -mxgot (or better -Wa,-xgot) _only_ for the binary
affected by the problem, including all its statically linked in
objects and libraries. Don't use any xgot object for anything outside
this build.

If you are unlucky, the program needs parts of glibc-nonshared, which
doesn't exist in a xgot version. This caused the failures for gcj and
ghc, and there's no workaround available for sarge (neither is for sid
yet).

> The package is a game and doesn't produce any
> shared libraries, so I don't think breaking binary compatibility would
> be a problem(as I understand -mxgot may do).

It's not a matter of binary compatibility but a silently breaking
toolchain.

> Is -mxgot the appropriate fix here?

Two observations:
 - The compiler used is gcc-3.4, which is not the default compiler.
   gcc-3.4 is known to break the ABI on mipsel WRT structure argument
   passing.

 - -mxgot is a relatively recent addition to gcc, it is still better to
   pass the equivalent -Wa,-xgot instead.


Thiemo



Reply to: