This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Wed, Jul 2, 2014 at 2:15 PM, Daniel Wilkerson
<daniel.wilkerson@gmail.com> wrote:
> /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?

No, that was the option to gcc.
The option to ld you need is:
-melf64btsmip
or
-melf64ltsmip

Depending on if you are doing big or little-endian.

Thanks,
Andrew


>
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]