request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM

Andrew Pinski pinskia@gmail.com
Wed Jul 2 21:10:00 GMT 2014


On Wed, Jul 2, 2014 at 2:06 PM, Daniel Wilkerson
<daniel.wilkerson@gmail.com> wrote:
> I wonder if I may trouble you with what I am sure is a simple linking
> question for someone who is not a beginner at linking internals such
> as myself.
>
> I am attempting to cross-compile to MIPS64 on an Ubuntu x86 machine.
> Here is my input file, zero.c:
>
>     int main() {
>       return 0;
>     }
>
> With some help from the LLVM people, I can now compile and assemble a
> .o file as follows:
>
> clang -o zero.o -target mips64 -integrated-as -c  -Wall -Wextra
> -Werror -O0 -g zero.c
>
> file zero.o
> zero.o: ELF 64-bit MSB  relocatable, MIPS, MIPS64 version 1 (SYSV), not stripped
>
> I configured and built binutils-2.24 (attempting to integrate with
> gcc) as follows:
>
> ../binutils-2.24/configure --target=mips64 --prefix=/home/dsw/gcc-4.8.3-mips64
>
> An now attempting to link the above-generated .o:
>
> /home/dsw/gcc-4.8.3-mips64/bin/mips64-ld -o zero zero.o
> /home/dsw/gcc-4.8.3-mips64/bin/mips64-ld: zero.o: ABI is incompatible
> with that of the selected emulation
> /home/dsw/gcc-4.8.3-mips64/bin/mips64-ld: failed to merge target
> specific data of file zero.o
> /home/dsw/gcc-4.8.3-mips64/bin/mips64-ld: warning: cannot find entry
> symbol _start; defaulting to 0000000000400000
> make: *** [zero] Error 1
>
> I thought perhaps running the linker through the cross-compiled gcc
> might help in some way, but no:
>
> /home/dsw/gcc-4.8.3-mips64/bin/mips64-gcc -o zero zero.o
> /home/dsw/gcc-4.8.3-mips64/lib/gcc/mips64/4.8.3/../../../../mips64/bin/ld:
> zero.o: ABI is incompatible with that of the selected emulation
> /home/dsw/gcc-4.8.3-mips64/lib/gcc/mips64/4.8.3/../../../../mips64/bin/ld:
> failed to merge target specific data of file zero.o
> /home/dsw/gcc-4.8.3-mips64/lib/gcc/mips64/4.8.3/../../../../mips64/bin/ld:
> warning: cannot find entry symbol _start; defaulting to
> 0000000000400028
> collect2: error: ld returned 1 exit status
> make: *** [zero] Error 1
>
> Feel free to point me to the documentation that I should have read
> before bothering you.
>

This sounds like ld and gcc both default to n32 while you are compiling for n64.

Add -mabi=64 to your command lines and try again.

Thanks,
Andrew


> Daniel



More information about the Binutils mailing list