I want to start to write an os kernel, and then, i found a document introducing multboot2 spec.
There are three example code files, named boot.S
, kernel.c
and multiboot2.h
, belonging to the multiboot2
branch of grub
project.
Firstly, i tried to compile and link the code with some option (using i686-elf-gcc) such as -nostartfiles
, -nodefaultlibs
and -ffreestanding
, but qemu showed me the format was error.
And then i found a file named Makefile.am
, and the compiler option in this file is -fno-builtin -nostdinc -O -g -Wall
, and the linker option in this file is -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
.
So i built the kernel with options above, and qemu started to booting the kernel(qemu-system-i386 -kernel kernel
). But the kernel traped into infinite loop immediately.
So i cloned the branch of the project, and used gnulib to generate some files and started make
but got some errors.
I don't show the error message here, because reading the document, i see what i need to do is just transforming boot.S
to binary file and pasting it in the front of the compiled and non-linked kernel file(kernel.o
), isn't it? How to complete it?