Link the Kernel

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
Christian Neubert

Link the Kernel

Post by Christian Neubert »

I use cygwin and compile so :

nasmw -o start.o -f elf start.asm
gcc -o kernel.o -c kernel.c
ld -T kernel.ls --oformat=elf32-i386 start.o kernel.o -o kernel

and I get the fault :

PE operations on non PE file

what is incorrect?

sorry for my bad english
roswell

Re: Link the Kernel

Post by roswell »

I also had this problem and i couldn't find any solution under cygwin.
It seems that you must build ld by yourself.

I skipped this problem using DJGPP.

LD accepts scripts under DJGPP.
But take care, you must compile using gcc provided with DJGPP.

If you compile with Cygwin and link with DJGPP, adresses in the kernel won't be good.

ROSWELL

Sorry for my english  I'm french.
The Legend

Re: Link the Kernel

Post by The Legend »

Can you tell me how to it DJGPP? I don't have the slightest clue how to tell that gcc to compile in elf, all it gives me is a a.out and the exe ...
K.J.

Re: Link the Kernel

Post by K.J. »

Do what? Link a kernel? Take a look at the "my suggestions" tutorial under the Docs and Tutorials section at my website. And as soon as I get the Memory Managment 1 up and the Getting Started tutorial up, I'll write a tutorial on using DJGPP and LD for OS Dev(it'll cover linking a kernel).

K.J.
Chris Giese

Re: Link the Kernel

Post by Chris Giese »

>...
>PE operations on non PE file
>...

Another bug in CygWin/MinGW32.

Try making a PE file, then use objcopy to convert to ELF.

ld -T kernel.ls --oformat=pei-i386 start.o kernel.o -o kernel.pe
objcopy -O elf32-i386 kernel.pe kernel.elf

If you use the GRUB bootloader with the "aout kludge", the kernel can be _any_ file format: ELF, PE, binary, whatever.
So you can use the "native" file format of the compiler.
Post Reply