Page 1 of 1
Ld error? File format not recognized
Posted: Mon Jun 09, 2008 7:49 am
by samoz
Hello all, I'm having some problems. I'm following James Molloy's tutorial and it's worked fine up to this point.
I'm at the 3rd part of the tutorial where it's talking about writing to the screen. I typed it all in and hit make, but I get the following error:
boot.o: file not recognized: File format not recognized
To make sure it wasn't a typo, I extracted the source from the tar available on the website, and still the same thing.
Why would this be happening?
I'm on windows by the way.
Posted: Mon Jun 09, 2008 8:02 am
by suthers
What compiler are you using?
Its obviously outputting in a format LD doesn't recognize.
You might need a cross compiler.
Jules
Re: Ld error? File format not recognized
Posted: Mon Jun 09, 2008 8:05 am
by JamesM
samoz wrote:Hello all, I'm having some problems. I'm following James Molloy's tutorial and it's worked fine up to this point.
I'm at the 3rd part of the tutorial where it's talking about writing to the screen. I typed it all in and hit make, but I get the following error:
boot.o: file not recognized: File format not recognized
To make sure it wasn't a typo, I extracted the source from the tar available on the website, and still the same thing.
Why would this be happening?
I'm on windows by the way.
make sure you "make clean" before you "make". I accidentally tarred up some object files in the downloads I put on my site, and they of course will only work properly in my build environment. "make clean" will remove all those .o's and force "make" to build them from scratch again.
If that's not the problem then I assume that the cygwin toolchain doesn't support ELF properly, but that's for someone more used to cygwin than me to work out.
Posted: Mon Jun 09, 2008 8:09 am
by samoz
I'm using DJGPP's gcc. gcc -v shows that it is 4.2.3
I did make clean, and the same issue arose...
Posted: Mon Jun 09, 2008 8:12 am
by JamesM
samoz wrote:I'm using DJGPP's gcc. gcc -v shows that it is 4.2.3
I did make clean, and the same issue arose...
execute the command "file boot.o" and paste what it returns.
Posted: Mon Jun 09, 2008 8:18 am
by samoz
boot.o: ELF 32-bit LSB relocatable 80386 Version 1
Posted: Mon Jun 09, 2008 8:25 am
by suthers
ld shouldn't have any problem linking it then...
(I think...)
Jules
edit; sorry I didn't catch on to the fact that you were using a UNIX like plaform...
Posted: Mon Jun 09, 2008 9:14 am
by JamesM
samoz wrote:boot.o: ELF 32-bit LSB relocatable 80386 Version 1
Hmm. interesting. I'll leave it to some cygwin users to identify the problem. It is cygwin you're using, isn't it? because otherwise your LD won't be configured to output ELF binaries.
Posted: Mon Jun 09, 2008 1:11 pm
by ollie123
Is it assembly code? Are you using NASM? If you are, make sure your command line is
Code: Select all
nasm -f elf -o boot.o [your asm file here]
Posted: Tue Jun 10, 2008 1:39 am
by JamesM
Is it assembly code? Are you using NASM? If you are, make sure your command line is
There's nothing wrong with the NASM command line, as you can see an ELF object is being output;
samoz wrote:boot.o: ELF 32-bit LSB relocatable 80386 Version 1
Posted: Tue Jun 10, 2008 7:24 am
by Zenith
IIRC, the Cygwin/Mingw LDs don't properly support ELF executables if you don't cross-compile them.
Posted: Wed Jun 11, 2008 11:44 am
by samoz
Do you mean cross compile them on UNIX and transfer them to Windows or cross-compile for Windows to UNIX?
Re: Ld error? File format not recognized
Posted: Wed Dec 22, 2010 4:13 pm
by MELLOMAN5123
try this
nasm -f coff -o boot.o
Re: Ld error? File format not recognized
Posted: Wed Dec 22, 2010 5:13 pm
by Combuster
Hmm, necroposting, doing so with a broken answer, and then asking to reply by mail.
None of the three is good etiquette