public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
@ 2014-07-02 21:07 Daniel Wilkerson
  2014-07-02 21:10 ` Andrew Pinski
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Wilkerson @ 2014-07-02 21:07 UTC (permalink / raw)
  To: binutils

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.

Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
  2014-07-02 21:07 request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM Daniel Wilkerson
@ 2014-07-02 21:10 ` Andrew Pinski
  2014-07-02 21:16   ` Daniel Wilkerson
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Pinski @ 2014-07-02 21:10 UTC (permalink / raw)
  To: Daniel Wilkerson; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
  2014-07-02 21:10 ` Andrew Pinski
@ 2014-07-02 21:16   ` Daniel Wilkerson
  2014-07-02 21:33     ` Andrew Pinski
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Wilkerson @ 2014-07-02 21:16 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: binutils

/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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
  2014-07-02 21:16   ` Daniel Wilkerson
@ 2014-07-02 21:33     ` Andrew Pinski
       [not found]       ` <CALzRTRkcGfTZUdPsHt++OvVsjJtfZvC-4fiyQ5WLU+zmB3jfPQ@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Pinski @ 2014-07-02 21:33 UTC (permalink / raw)
  To: Daniel Wilkerson; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fwd: request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM
       [not found]       ` <CALzRTRkcGfTZUdPsHt++OvVsjJtfZvC-4fiyQ5WLU+zmB3jfPQ@mail.gmail.com>
@ 2014-07-04  0:59         ` Daniel Wilkerson
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Wilkerson @ 2014-07-04  0:59 UTC (permalink / raw)
  To: Binutils; +Cc: Andrew Pinski

I should have sent this to the list as well: -melf64btsmip
does not seem to be working (see below).

I seem to be missing something here about how to configure and use
binutils.  Can I trouble someone to fill me in on the basic approach?
I want to link MIPS64 .o files, in particular those generated by
Clang/LLVM with their integrated assembler, like this:

clang++ -target mips64 -integrated-as -c -O0 -g -o zero.mips64_o zero.cc

Daniel

---------- Forwarded message ----------
From: Daniel Wilkerson <daniel.wilkerson@gmail.com>
Date: Wed, Jul 2, 2014 at 3:34 PM
Subject: Re: request for assistance in using binutils to link a .o
which was cross-compiled to mips64 using Clang/LLVM
To: Andrew Pinski <pinskia@gmail.com>


On Wed, Jul 2, 2014 at 2:33 PM, Andrew Pinski <pinskia@gmail.com> wrote:

> The option to ld you need is:
> -melf64btsmip
> or
> -melf64ltsmip
>
> Depending on if you are doing big or little-endian.

/home/dsw/gcc-4.8.3-mips64/bin/mips64-ld -melf64btsmip -o zero zero.o
/home/dsw/gcc-4.8.3-mips64/bin/mips64-ld: unrecognised emulation mode:
elf64btsmip
Supported emulations: elf32ebmip
make: *** [zero] Error 1

Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-04  0:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-02 21:07 request for assistance in using binutils to link a .o which was cross-compiled to mips64 using Clang/LLVM Daniel Wilkerson
2014-07-02 21:10 ` Andrew Pinski
2014-07-02 21:16   ` Daniel Wilkerson
2014-07-02 21:33     ` Andrew Pinski
     [not found]       ` <CALzRTRkcGfTZUdPsHt++OvVsjJtfZvC-4fiyQ5WLU+zmB3jfPQ@mail.gmail.com>
2014-07-04  0:59         ` Fwd: " Daniel Wilkerson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).