Page 1 of 1

How can i link Linux elf file on Win32 using ld???

Posted: Thu Jul 05, 2012 12:55 am
by teedev
When i linking object file into elf (Using Win32) it show this error

Code: Select all

..\..\MinGW\bin\ld: unrecognised emulation mode: elf_i386
Supported emulations: i386pe
how can i set ld to support elf_i386 ???


thank you.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Thu Jul 05, 2012 1:17 am
by teedev
Ok! my problem are fixed.
while wait for answer, i still searched 2 days how to link it :)

and get this link http://cygwin.com/ml/cygwin/2006-11/msg00323.html

i forgot using 'objcopy' (never use it)
-------------
my linking code (fixed)

using on win32

Code: Select all

fasm kernel.asm
ld  -Tlink.ld  -o  kernel.out  kernel.o
objcopy -I elf32-i386 kernel.out kernel
and my code can execute!!! :mrgreen:

thank. __/\__

Re: How can i link Linux elf file on Win32 using ld???

Posted: Mon Jul 16, 2012 6:55 pm
by Tosi
Build a cross compiler. It will save you problems later.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Wed Jul 18, 2012 9:50 am
by Love4Boobies
You mean cross-Binutils.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Wed Jul 18, 2012 9:15 pm
by Tosi
Love4Boobies wrote:You mean cross-Binutils.
Both should be built, since using a host compiler with a cross-linker and assembler sounds like a Bad Idea.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Wed Jul 18, 2012 10:38 pm
by Love4Boobies
Why are you assuming he's using a compiler?

Re: How can i link Linux elf file on Win32 using ld???

Posted: Wed Jul 18, 2012 10:49 pm
by Tosi
Love4Boobies wrote:Why are you assuming he's using a compiler?
I just reflexively assumed he was, as it makes sense to me that anybody using assembly (i.e., binutils only or binutils + nasm or some other assembler) would know what they are doing.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Wed Jul 18, 2012 10:52 pm
by Love4Boobies
I didn't necessarily mean he was interested in GAS either. Maybe he just has the object files and wished to link them. After all, we're in the Everything Else forum.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Fri Jul 20, 2012 8:41 am
by arabasso
Exactly, you can use objcopy to create a binary format other than PE (when you use it, you can leave your linker script without binary type information).

Another is about the name of functions and variables, which adds a MinGW "_" before the name of each function. If you do not want that "junk" in your kernel code (and also make your code more compatible with a possible build in Linux), just pass the parameter "-fno-underscore" for GCC.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Fri Jul 20, 2012 3:25 pm
by Combuster
And you'll end up adding options and more options until you covered all hidden "features" of mingw that will pop up over time, until you find that that particular compiler is inherently broken to do your work.

The cross-compiler is the recommended solution for a reason.

Re: How can i link Linux elf file on Win32 using ld???

Posted: Fri Jul 20, 2012 10:27 pm
by Love4Boobies
For the second time, cross-Binutils. :)