Page 1 of 1
problem in linking Bkerndev
Posted: Fri Apr 22, 2005 8:24 pm
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....
Re:problem in linking Bkerndev
Posted: Sat Apr 23, 2005 9:01 am
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.
Re:problem in linking Bkerndev
Posted: Sat Apr 23, 2005 5:35 pm
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...
Re:problem in linking Bkerndev
Posted: Sat Apr 23, 2005 5:55 pm
by Curufir
Well the problem seems to lie with start.o.
Try using ELF or COFF as the nasm option instead of AOUT.
Re:problem in linking Bkerndev
Posted: Sun Apr 24, 2005 3:27 am
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.
Re:problem in linking Bkerndev
Posted: Sun Apr 24, 2005 3:49 pm
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
)
Re:problem in linking Bkerndev
Posted: Wed Apr 27, 2005 1:16 pm
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 ?
Re:problem in linking Bkerndev
Posted: Fri Apr 29, 2005 3:04 am
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
Problem in linking Bkerndev
Posted: Mon Jun 13, 2005 9:27 am
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?
Re:problem in linking Bkerndev
Posted: Tue Jun 14, 2005 12:01 pm
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
Re:problem in linking Bkerndev
Posted: Wed Jun 15, 2005 4:43 am
by calpis
Thanks, Yeah, I did that, and it kind of work after I removed or add the underscores to tackle the undefined references.