This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
- From: Daniel Wilkerson <daniel dot wilkerson at gmail dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Wed, 2 Jul 2014 14:15:22 -0700
- Subject: Re: request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
- Authentication-results: sourceware.org; auth=none
- References: <CALzRTRkWA-K3jjPRSmTOpV_Nxx==vuVSMc027KeKJ3EkYW3tHw at mail dot gmail dot com> <CA+=Sn1khVkpR6KAZ1BEtxfhbmUizbwWRsOiqFt4uKotzrH-7YQ at mail dot gmail dot com>
/home/dsw/gcc-4.8.3-mips64/bin/mips64-ld -mabi=64 -o zero zero.o
/home/dsw/gcc-4.8.3-mips64/bin/mips64-ld: unrecognised emulation mode: abi=64
Supported emulations: elf32ebmip
make: *** [zero] Error 1
Do I need to reconfigure binutils for a different emulation?
Daniel
On Wed, Jul 2, 2014 at 2:10 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> 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