Question

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.

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top