I'd like to build an embedded kernel for an x86 machine using Visual C++. I have some C and assembly code files to compile and I'd like to link them all together in a way that is compatible with a Multiboot bootloader like GRUB.
+4
A:
OSDev has a wiki entry on Visual Studio, that may provide some insight, especially with the links to Kaushik Srenevasan's blog entries on the subject of PE kernels designed to be loaded by multiboot-based bootloaders (like GRUB).
A couple of large, broad-strokes things you should know:
- In the multiboot header, you need to use the AOUT kludge.
- You need to specify the /BASE:0x100000 argument to the linker, so the final binary code is based to where the bootloader is going to put it.
- Your kernel's entry point (usually called '
kmain
') needs to have__declspec(noreturn)
on it, and you will need to do an__asm { hlt }
instead of returning.
Alex Lyman
2009-03-21 05:43:26
Copy-and-paste doesn't work here, either, but points to the mistake: it looks like "...kernels-using%5F03.html", but should be "...kernels-using_03.html".
Anonymous Coward
2009-03-21 06:03:12
Alex Lyman
2009-03-21 20:06:15
Ok, I sent an email to the SO Team, and they pointed out that there are other ways to make a link, so I switched it to one that works.
Alex Lyman
2009-03-21 22:10:54
Great links, thanks for this info
Frank Miller
2009-03-22 05:01:02