I have moved my blog to Wordpress at theunixgeek.wordpress.com. I will still be checking back periodically on this one as well, though. 19 April 2009


Merging Mkdir and Cd | 280 Slides Interview | I Switched to KDE 4

clickable portals

Tuesday, December 18, 2007

Writing a Kernel

The code is strange but the steps are simple. Once you know C, you're ready to go!

I recently decided to haphazardly (my biggest mistake) write an operating system kernel. I used the OSDev Wiki Barebones as a base for it. Here's what I used to compile it. Have fun!

nasm -f elf -o loader.o loader.s
gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
ld -T linker.ld kernel.o loader.o -o kernel.elf

Now on to the next step of this kernel. Make sure you know the C language in depth, especially pointers, memory management, data structures, and algorithms.

Need help? OSDever and the OSDev.


Saleh said...

I get an error when linking:
loader.o: in function 'loader'
loader.s:(.text+0x14): undefined reference to 'kmain'