Ld.exe problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Jamie

Ld.exe problem

Post by Jamie »

when i use the command

"ld -T link.ld -o kernel.bin ks.o kernel.o" it keep getting the error message "ks.0: file not recongnized: File format not recognized"

ne1 know what i'm doing wrong and sort it?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Ld.exe problem

Post by Pype.Clicker »

sounds like the output format of ks.o isn't recognized by your linker version. You should know that LD.EXE (likely to be a part of DJGPP) expect COFF files and nothing but COFF files as input.

Just make sure you're compatible with yourself, and everything should be fine ...

hint: objdump --help should tell you which output formats are supported by your implementation of binutils.

hint?: would by anychance "ks.o" be a nasmsembled file ?
Jamie

Re:Ld.exe problem

Post by Jamie »

ks.o is build in nasm.

As i'm new every you you said went right of my head.
I'm trying to compile this if it helps http://osdev.neopages.net/tutorials/basickernel.php?the_id=12

i'm using nasm 0.98.38 and DJGPP.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Ld.exe problem

Post by Pype.Clicker »

i don't think DjGpp has a support for a.out files. Instead of using

Code: Select all

nasm -f aout kernel_start.asm -o ks.o
try

Code: Select all

nasm -f coff kernel_start.asm -o ks.o
Jamie

Re:Ld.exe problem

Post by Jamie »

Still getting the same error >:(
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Ld.exe problem

Post by Pype.Clicker »

what does "ld --help" says about "supported targets" ?
Jamie

Re:Ld.exe problem

Post by Jamie »

support targets:

coff-go32
coff-go32-exe
a.out-i386
srec
symbolsrec
tekhex
binary
ihex
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Ld.exe problem

Post by Pype.Clicker »

Jamie wrote: error message "ks.0: file not recongnized: File format not recognized"
Is it a typo, or does it *really* display "ks.0" with a 'zero' or a big 'O' rather than a small 'o' ?

what do objdump -h ks.o say ?
jamie

Re:Ld.exe problem

Post by jamie »

objdump -t ks.o :

ks.o : file format a.out-i386

Sections:

0 .text 00000008 00000000 00000000 00000000 2**3
CONTENTS, ALLOC, LOAD, RELOC, CODE
1 .data 00000000 00000008 00000008 00000028 2**3
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000008 00000008 00000000 2**3
ALLOC
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Ld.exe problem

Post by Pype.Clicker »

doh !? veryveryweird. maybe removing all the .o files and do a full clean compile will help you, but honestly i have a doubt. Maybe there's something corrupted with your Djgpp installation too (make sure your %PATH% environment variable is not making you use an older/different ld.exe as the one you expect, or something like this) ...

I must admit that this goes beyond what i can track. Everything looks fine, except that it doesn't work ???
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Ld.exe problem

Post by Neo »

i just wanted to know does DJGPP output elf files?
Only Human
kaos

Re:Ld.exe problem

Post by kaos »

You can recompile parts of DJGPP to make it output elf files, but the default distribution as of today's date does not.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Ld.exe problem

Post by Pype.Clicker »

kaos wrote: You can recompile parts of DJGPP to make it output elf files, but the default distribution as of today's date does not.
I think there is a special-ELF-release of DJGPP (or was it cygwin ? i know DF knows ;] )somewhere ... Search it hard and you should find it ...
Post Reply