problem in linking Bkerndev

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
mar-rih

problem in linking Bkerndev

Post by mar-rih »

Hi....

I try to build the bkerndev, the toutorial in Boanfide site

http://osdever.net/bkerndev/index.php?the_id=90

but this bug apear to me when Likage try to link the kernel....

G:\Projects\Marwan\Operating System\Rsources\startker\1\Sources>ld -T link.ld -o
tools/kernel.bin obj/main.o obj/scrn.o obj/gdt.o obj/idt.o obj/isrs.o obj/irq.o
obj/timer.o obj/start.o obj/kb.o
obj/start.o: file not recognized: File format not recognized
could anybody interpret this problem please....
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:problem in linking Bkerndev

Post by distantvoices »

@admin: could you move this to osdev section? thx. :-)

@mar-rih: the object file you have supplied is in a format which thelinker canna interpret. It does know about certain formats, but 1. you have to stick to one object format, and 2. if you have told f. ex. nasm to create a binary object file, this won't link to any other object files - so the linker might have a valid reason to refuse linking. :-)

Just give us the script with which you are compiling the stuff.

Maybe we can get the knack together.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
mar-rih

Re:problem in linking Bkerndev

Post by mar-rih »

The format of the file is -aout

the building command for the kernel is thes
nasm -f aout boot/start.asm -o obj/start.o

gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/main.o ker/main.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/scrn.o ker/scrn.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/gdt.o ker/gdt.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/idt.o ker/idt.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/isrs.o ker/isrs.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/irq.o ker/irq.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/timer.o ker/timer.c
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o obj/kb.o ker/kb.c

ld -T link.ld -o tools/kernel.bin obj/main.o obj/scrn.o obj/gdt.o obj/idt.o obj/isrs.o obj/irq.o obj/timer.o obj/start.o obj/kb.o
and i have attached the link file...
Curufir

Re:problem in linking Bkerndev

Post by Curufir »

Well the problem seems to lie with start.o.

Try using ELF or COFF as the nasm option instead of AOUT.
mar-rih

Re:problem in linking Bkerndev

Post by mar-rih »

Well the problem seems to lie with start.o.

Try using ELF or COFF as the nasm option instead of AOUT.


i changed the Format of output file, to COFF and ELF but another error at linkage

this message appear when linking

Code: Select all

ld -T link.ld -o tools/kernel.bin obj/main.o obj/scrn.o obj/gdt.o obj/idt.o obj/isrs.o obj/irq.o obj/timer.o obj/start.o obj/kb.o

ld: PE operations on non PE file.
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:problem in linking Bkerndev

Post by Pype.Clicker »

that sounds typical from a cygwin/mingw installation that only supports windows .EXE files. The best we have found to work this out is to build yourself a proper CrossCompiler that will support your target environment (be it ELF, COFF or whatever).

You should find help about it in the FAQ (click the large "megatokyo.com" banner above ;) )
mar-rih

Re:problem in linking Bkerndev

Post by mar-rih »

My problem until now did not solved...!!!!

@Pype.Clicker :
i can't understand your last reply...
and i have gone at the Link in OS-FAQ and read the page..

do you mean that my compiler MinGw is the Problem ?
do you mean i must uninstall mingw and install djpp instead ?
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:problem in linking Bkerndev

Post by Pype.Clicker »

indeed, i think your MingW is the problem. I don't suggest DJGPP, but rather CYGWIN.

More precisely, i suggest you get CYGWIN and *then* rebuild a compiler suitable to OsDev using that CYGWIN.

It may sound scary, but compared to what i had to do to get kernel loaded using DJGPP and tools of mine, it's piece of cake ;)
calpis

Problem in linking Bkerndev

Post by calpis »

Hi, I had the same problem with Bkerndev linking as well. I needs some help please.

I did nasm -f aout -o start.o start.asm and it created start.o
But when i try to link it with other object files, only start.o has generate this error message

start.o : file not recognized: File format not recognized

Then I changed the file format to elf and coff.
It generated so many error message saying undefined reference in functions 'stublet', _gdt_flush and all the rest of it.

I m using a cross complier gcc3.4.2 (mingw special) on osx. Targeted for i586-elf. I hope that the problem doesn't reside on mingw special. Coz it worked fine when I tried with loader.s instead of start.asm.

I think the problem might be my nasm. I complied it with --target to i586-elf...is it correct?
Kim

Re:problem in linking Bkerndev

Post by Kim »

You have to use elf format as output format for nasm, when using an linker that needs elf objects as input.

nasm -f elf -o start.o start.asm

The stub and linker script on that link can not be used for an elf format kernel.

There's an GRUB elf format kernel barebone on the FAQ.

Make sure you have a crosscompiled gnu linker to elf format.

http://www.osdev.org/osfaq2/index.php/BareBones?PHPSESSID=422099fc65fd7d6dff90e1a4cb3a2b84
http://www.osdev.org/osfaq2/index.php/NasmAllInOne#loaderx2ex2e.s
http://www.osdev.org/osfaq2/index.php/GCC%20Cross-Compiler?PHPSESSID=422099fc65fd7d6dff90e1a4cb3a2b84
calpis

Re:problem in linking Bkerndev

Post by calpis »

Thanks, Yeah, I did that, and it kind of work after I removed or add the underscores to tackle the undefined references.
Post Reply