glauxosdever wrote:
How are you building the kernel? Specifically, are you using a cross compiler? I'd assume your system compiler creates PE output (as you seem to be on Windows), and probably does other things that don't work for a freestanding executable.
I'm using the precompiled i686-elf toolchain thing (
https://github.com/lordmilko/i686-elf-tools). I don't know if that's ok, but it seems to run fine.
My Makefile:
Code: Select all
GCCPARAMS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra
NASMPARAMS = -f elf32
LINKERPARAMS = -ffreestanding -O2 -nostdlib -lgcc
cobjects = $(patsubst src/%.c,objects/%.o,$(wildcard src/*.c))
asmobjects = $(patsubst src/%.asm,objects/%.o,$(wildcard src/*.asm))
objects = $(cobjects) $(asmobjects)
objects/%.o: src/%.c
i686-elf/bin/i686-elf-gcc $(GCCPARAMS) -o $@ -c $<
objects/%.o: src/%.asm
nasm $(NASMPARAMS) $< -o $@
bin/kernel.bin: src/linker.ld $(objects)
i686-elf/bin/i686-elf-gcc -T $< -o $@ $(objects) $(LINKERPARAMS)
songziming wrote:
`-kernel` requires bzImage or multiboot format kernel. Either make it ELF or provide your address fields of multiboot header.
I'm confused. So it's either make it ELF
or have the multiboot header? I have the multiboot header defined so it should be there.
I don't know what you mean by "provide address fields".
songziming wrote:
Use `-f elf` to make NASM generate ELF format objects, and use ld to link them.
I'm doing just that. I've originally had a typo in the nasm command, I was using `-felf32` (without the space) but it doesn't seem to behave any different now that I've changed it.
Should I use ld for linking though? The tutorial suggests using i686-elf-gcc.
Sorry if I'm missing some obvious points and thanks for understanding. I've thrown myself into OS development with little background.