mips64 ld GOT problem

Stacey Son sson at FreeBSD.org
Sun Jul 27 19:39:36 UTC 2014


Hi David:

Compiling with the cmake option "-DBUILD_SHARED_LIBS=True" does get it pass linking 'opt' but it later fails later on...

[ 73%] Building CXX object tools/clang/lib/AST/CMakeFiles/clangAST.dir/VTTBuilder.cpp.o
Linking CXX shared library ../../../../lib/libclangAST.so
[...]
/home/sson/llvm/tools/clang/lib/AST/ASTContext.cpp:(.text+0x710): relocation truncated to fit: R_MIPS_CALL16 against `bool llvm::isa<clang::ObjCPropertyDecl, clang::Decl const*>(clang::Decl const* const&)'
[...]
/home/sson/llvm/tools/clang/lib/AST/ASTContext.cpp:(.text+0x5a98): additional relocation overflows omitted from the output
clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

As for enabling optimization, when I use "-DCMAKE_BUILD_TYPE=Release" or "-DCMAKE_BUILD_TYPE=MinSizeRel" with the cmake I get an "EmitRawText called on an MCStreamer that doesn't support it,  something must not be fully mc'ized" abort.   Only "-DCMAKE_BUILD_TYPE=Debug" or "-DCMAKE_BUILD_TYPE=None" seems to work.   Maybe I am not enabling the optimization correctly?

I have been able to get ld from binutils 2.24 to mostly work.  It will link binaries with "-static" but dynamic binaries are still a problem.  It seems the default ldscript is not quite right or something.

-stacey.

On Jul 26, 2014, at 6:46 AM, David Chisnall <theraven at FreeBSD.org> wrote:

> The only way that I've ever got llvm to compile for MIPS has been by enabling shared libraries, enabling optimisation, and disabling debug info.  This gave each shared lib a small enough GOT for our binutils linker to work.
> 
> Newer binutils supports multi-GOT (GOT is split and different GOTs are installed by some calls) and large-GOT (GOT accesses use register offsets) modes.
> 
> David
> 
> On 25 Jul 2014, at 23:27, Stacey Son <sson at FreeBSD.org> wrote:
> 
>> 
>> Hi Warner...
>> 
>> On Jul 25, 2014, at 11:26 AM, Warner Losh <imp at bsdimp.com> wrote:
>> 
>>> 
>>> On Jul 25, 2014, at 9:24 AM, Stacey Son <sson at me.com> wrote:
>>> 
>>>> Hi all:
>>>> 
>>>> I have been trying to bootstrap clang/llvm 3.5 for mips64 (i.e. cross build clang/llvm 3.5 for mips64 using clang/llvm 3.5) but run into the following linker problem (see below) in about the midway point as it is trying to link 'opt'.   The assertions that fail are the following:
>>>> 
>>>> BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/home/sson/freebsd/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elfxx-mips.c:7455
>>>> 
>>>>               BFD_ASSERT (g->assigned_gotno - g->local_gotno
>>>>                           <= g->global_gotno);
>>>> 
>>>> BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/home/sson/freebsd/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elfxx-mips.c:2767
>>>> 
>>>> /* There should have been enough room in the symbol table to
>>>>  accommodate both the GOT and non-GOT symbols.  */
>>>> BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
>>>> 
>>>> BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail /usr/home/sson/freebsd/gnu/usr.bin/binutils/libbfd/../../../../contrib/binutils/bfd/elfxx-mips.c:10282
>>>> 
>>>>   /* Make sure we didn't grow the global .got region.  */
>>>>   dynobj = elf_hash_table (info)->dynobj;
>>>>   got = mips_elf_got_section (dynobj, FALSE);
>>>>   g = mips_elf_section_data (got)->u.got_info;
>>>> 
>>>>   if (g->global_gotsym != NULL)
>>>>     BFD_ASSERT ((elf_hash_table (info)->dynsymcount
>>>>                  - g->global_gotsym->dynindx)
>>>>                 <= g->global_gotno);
>>>> 
>>>> Does anyone have an idea for a work around or fix?
>>> 
>>> Silly question: does using the latest binutils fix this problem?
>> 
>> Is there a stable port of the latest binutils to mips?  Does someone have some patches?  I did tried TheRaven's port of the 2.18 binutils but it seemed that 'ld' wasn't very happy.  It didn't like any of the object files I offered it.
>> 
>>> Failing that, perhaps we need to specify a larger GOT region that we do today?  IIRC, that’s specified with -g on the linker line, Try adding “-G0”. I have a vague recollection we always used to do this, but moved it to be a default (or maybe other systems have the default and we still need to add it). It doesn’t look like it is being added from the output that you’ve posted. IIRC, it has to be specified on all the compiler invocations as well.
>> 
>> Reading the man page implies  -Gvalue/--gpsize=value is only for ECOFF binaries.  I tried it anyway and it didn't seem to help.
>> 
>> -stacey.
> 



More information about the freebsd-mips mailing list