mips64 ld GOT problem

Warner Losh imp at bsdimp.com
Fri Jul 25 16:26:45 UTC 2014


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?

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.

But who knows, I may be crazy.

Warner

> Thanks in advance,
> 
> -stacey.
> 
> ----
> The full  ld crash message:
> 
> [ 50%] Building CXX object tools/opt/CMakeFiles/opt.dir/opt.cpp.o
> Linking CXX executable ../../bin/opt
> /home/sson/sdk/bin/mips64-unknown-freebsd-ld: 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
> /home/sson/sdk/bin/mips64-unknown-freebsd-ld: 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
> /home/sson/sdk/bin/mips64-unknown-freebsd-ld: 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
> /home/sson/sdk/bin/mips64-unknown-freebsd-ld: 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
> /home/sson/sdk/bin/mips64-unknown-freebsd-ld: 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
> CMakeFiles/opt.dir/PrintSCC.cpp.o: In function `llvm::scc_iterator<llvm::CallGraph*, llvm::GraphTraits<llvm::CallGraph*> >::hasLoop() const':
> /usr/home/sson/llvm/tools/opt/PrintSCC.cpp:(.text._ZNK4llvm12scc_iteratorIPNS_9CallGraphENS_11GraphTraitsIS2_EEE7hasLoopEv[_ZNK4llvm12scc_iteratorIPNS_9CallGraphENS_11GraphTraitsIS2_EEE7hasLoopEv]+0x108): relocation truncated to fit: R_MIPS_CALL16 against `llvm::GraphTraits<llvm::CallGraphNode*>::child_end(llvm::CallGraphNode*)'
> CMakeFiles/opt.dir/PrintSCC.cpp.o: In function `llvm::scc_iterator<llvm::CallGraph*, llvm::GraphTraits<llvm::CallGraph*> >::GetNextSCC()':
> /usr/home/sson/llvm/tools/opt/PrintSCC.cpp:(.text._ZN4llvm12scc_iteratorIPNS_9CallGraphENS_11GraphTraitsIS2_EEE10GetNextSCCEv[_ZN4llvm12scc_iteratorIPNS_9CallGraphENS_11GraphTraitsIS2_EEE10GetNextSCCEv]+0x150): relocation truncated to fit: R_MIPS_CALL16 against `llvm::GraphTraits<llvm::CallGraphNode*>::child_end(llvm::CallGraphNode*)'
> CMakeFiles/opt.dir/PrintSCC.cpp.o: In function `llvm::scc_iterator<llvm::CallGraph*, llvm::GraphTraits<llvm::CallGraph*> >::DFSVisitChildren()':
> /usr/home/sson/llvm/tools/opt/PrintSCC.cpp:(.text._ZN4llvm12scc_iteratorIPNS_9CallGraphENS_11GraphTraitsIS2_EEE16DFSVisitChildrenEv[_ZN4llvm12scc_iteratorIPNS_9CallGraphENS_11GraphTraitsIS2_EEE16DFSVisitChildrenEv]+0xb0): relocation truncated to fit: R_MIPS_CALL16 against `llvm::GraphTraits<llvm::CallGraphNode*>::child_end(llvm::CallGraphNode*)'
> ../../lib/libLLVMMipsCodeGen.a(Mips16ISelDAGToDAG.cpp.o): In function `$BB72_54':
> /usr/home/sson/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp:(.text._ZNK4llvm16MipsDAGToDAGISel18CheckNodePredicateEPNS_6SDNodeEj[_ZNK4llvm16MipsDAGToDAGISel18CheckNodePredicateEPNS_6SDNodeEj]+0x1214): relocation truncated to fit: R_MIPS_CALL16 against `llvm::ISD::isBuildVectorAllOnes(llvm::SDNode const*)'
> ../../lib/libLLVMMipsCodeGen.a(MipsSEISelLowering.cpp.o): In function `performXORCombine(llvm::SDNode*, llvm::SelectionDAG&, llvm::MipsSubtarget const&)':
> /usr/home/sson/llvm/lib/Target/Mips/MipsSEISelLowering.cpp:(.text._ZL17performXORCombinePN4llvm6SDNodeERNS_12SelectionDAGERKNS_13MipsSubtargetE+0x180): relocation truncated to fit: R_MIPS_CALL16 against `llvm::ISD::isBuildVectorAllOnes(llvm::SDNode const*)'
> /usr/home/sson/llvm/lib/Target/Mips/MipsSEISelLowering.cpp:(.text._ZL17performXORCombinePN4llvm6SDNodeERNS_12SelectionDAGERKNS_13MipsSubtargetE+0x1d8): relocation truncated to fit: R_MIPS_CALL16 against `llvm::ISD::isBuildVectorAllOnes(llvm::SDNode const*)'
> ../../lib/libLLVMMipsDesc.a(MipsOptionRecord.cpp.o): In function `llvm::DenseMapBase<llvm::DenseMap<llvm::MCSection const*, llvm::MCSectionData*, llvm::DenseMapInfo<llvm::MCSection const*> >, llvm::MCSection const*, llvm::MCSectionData*, llvm::DenseMapInfo<llvm::MCSection const*> >::grow(unsigned int)':
> /usr/home/sson/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp:(.text._ZN4llvm12DenseMapBaseINS_8DenseMapIPKNS_9MCSectionEPNS_13MCSectionDataENS_12DenseMapInfoIS4_EEEES4_S6_S8_E4growEj[_ZN4llvm12DenseMapBaseINS_8DenseMapIPKNS_9MCSectionEPNS_13MCSectionDataENS_12DenseMapInfoIS4_EEEES4_S6_S8_E4growEj]+0x28): relocation truncated to fit: R_MIPS_CALL16 against `llvm::DenseMap<llvm::MCSection const*, llvm::MCSectionData*, llvm::DenseMapInfo<llvm::MCSection const*> >::grow(unsigned int)'
> clang-3.5: error: linker command failed with exit code 1 (use -v to see invocation)
> *** Error code 1
> 
> ld invocation:
> 
> /home/sson/sdk/bin/mips64-unknown-freebsd-ld --sysroot=/home/sson/sdk --eh-frame-hdr -dynamic-linker /libexec/ld
> -elf.so.1 --enable-new-dtags -o ../../bin/opt /home/sson/sdk/usr/lib/crt1.o /home/sson/sdk/usr/lib/crti.o /home/
> sson/sdk/usr/lib/crtbegin.o -L/usr/local/lib -L/home/sson/sdk/usr/lib -z origin --export-dynamic CMakeFiles/opt.
> dir/AnalysisWrappers.cpp.o CMakeFiles/opt.dir/BreakpointPrinter.cpp.o CMakeFiles/opt.dir/GraphPrinters.cpp.o CMa
> keFiles/opt.dir/NewPMDriver.cpp.o CMakeFiles/opt.dir/Passes.cpp.o CMakeFiles/opt.dir/PassPrinters.cpp.o CMakeFil
> es/opt.dir/PrintSCC.cpp.o CMakeFiles/opt.dir/opt.cpp.o ../../lib/libLLVMMipsCodeGen.a ../../lib/libLLVMMipsAsmPr
> inter.a ../../lib/libLLVMMipsAsmParser.a ../../lib/libLLVMMipsDesc.a ../../lib/libLLVMMipsInfo.a ../../lib/libLL
> VMMipsDisassembler.a ../../lib/libLLVMAnalysis.a ../../lib/libLLVMBitWriter.a ../../lib/libLLVMCodeGen.a ../../l
> ib/libLLVMCore.a ../../lib/libLLVMipa.a ../../lib/libLLVMipo.a ../../lib/libLLVMIRReader.a ../../lib/libLLVMInst
> Combine.a ../../lib/libLLVMInstrumentation.a ../../lib/libLLVMMC.a ../../lib/libLLVMObjCARCOpts.a ../../lib/libL
> LVMScalarOpts.a ../../lib/libLLVMSupport.a ../../lib/libLLVMTarget.a ../../lib/libLLVMTransformUtils.a ../../lib
> /libLLVMVectorize.a ../../lib/libLLVMAsmPrinter.a ../../lib/libLLVMSelectionDAG.a ../../lib/libLLVMCodeGen.a ../
> ../lib/libLLVMMipsAsmPrinter.a ../../lib/libLLVMMCParser.a ../../lib/libLLVMMipsInfo.a ../../lib/libLLVMMCDisass
> embler.a ../../lib/libLLVMScalarOpts.a ../../lib/libLLVMInstCombine.a ../../lib/libLLVMAsmParser.a ../../lib/lib
> LLVMBitReader.a ../../lib/libLLVMTransformUtils.a ../../lib/libLLVMipa.a ../../lib/libLLVMAnalysis.a ../../lib/l
> ibLLVMTarget.a ../../lib/libLLVMCore.a ../../lib/libLLVMMC.a ../../lib/libLLVMSupport.a --library=rt --library=t
> info --library=pthread --library=z -rpath $ORIGIN/../lib --library=c++ --library=m --library=gcc --as-needed --l
> ibrary=gcc_s --no-as-needed --library=c --library=gcc --as-needed --library=gcc_s --no-as-needed /home/sson/sdk/
> usr/lib/crtend.o /home/sson/sdk/usr/lib/crtn.o
> 
> _______________________________________________
> freebsd-mips at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-mips
> To unsubscribe, send any mail to "freebsd-mips-unsubscribe at freebsd.org"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-mips/attachments/20140725/8d50dbe3/attachment.sig>


More information about the freebsd-mips mailing list