OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 5:15 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Ld error? File format not recognized
PostPosted: Mon Jun 09, 2008 7:49 am 
Offline
Member
Member
User avatar

Joined: Sun Jun 01, 2008 1:16 pm
Posts: 59
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 8:02 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
What compiler are you using?
Its obviously outputting in a format LD doesn't recognize.
You might need a cross compiler.
Jules


Top
 Profile  
 
 Post subject: Re: Ld error? File format not recognized
PostPosted: Mon Jun 09, 2008 8:05 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
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.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 8:09 am 
Offline
Member
Member
User avatar

Joined: Sun Jun 01, 2008 1:16 pm
Posts: 59
I'm using DJGPP's gcc. gcc -v shows that it is 4.2.3

I did make clean, and the same issue arose...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 8:12 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
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.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 8:18 am 
Offline
Member
Member
User avatar

Joined: Sun Jun 01, 2008 1:16 pm
Posts: 59
boot.o: ELF 32-bit LSB relocatable 80386 Version 1


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 8:25 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
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...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 9:14 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
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.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 09, 2008 1:11 pm 
Offline
Member
Member
User avatar

Joined: Tue May 27, 2008 2:42 am
Posts: 26
Location: Great Yarmouth, Norfolk, United Kingdom
Is it assembly code? Are you using NASM? If you are, make sure your command line is
Code:
nasm -f elf -o boot.o [your asm file here]

_________________
NEW TO OPERATING SYSTEM DEVELOPMENT
Good OS Development Tutorials: http://www.brokenthorn.com/Resources/OSDevIndex.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 10, 2008 1:39 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Quote:
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

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 10, 2008 7:24 am 
Offline
Member
Member
User avatar

Joined: Tue Apr 10, 2007 4:42 pm
Posts: 224
IIRC, the Cygwin/Mingw LDs don't properly support ELF executables if you don't cross-compile them.

_________________
"Sufficiently advanced stupidity is indistinguishable from malice."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 11, 2008 11:44 am 
Offline
Member
Member
User avatar

Joined: Sun Jun 01, 2008 1:16 pm
Posts: 59
Do you mean cross compile them on UNIX and transfer them to Windows or cross-compile for Windows to UNIX?


Top
 Profile  
 
 Post subject: Re: Ld error? File format not recognized
PostPosted: Wed Dec 22, 2010 4:13 pm 
Offline

Joined: Wed Dec 22, 2010 3:58 pm
Posts: 1
try this
nasm -f coff -o boot.o


Last edited by MELLOMAN5123 on Sun Mar 13, 2011 9:36 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Ld error? File format not recognized
PostPosted: Wed Dec 22, 2010 5:13 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Hmm, necroposting, doing so with a broken answer, and then asking to reply by mail.

None of the three is good etiquette :roll:

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot], Majestic-12 [Bot] and 153 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group