Bare Bones Compilation
Posted: Sat Oct 06, 2012 12:00 am
Hello,
I'm following the http://wiki.osdev.org/Bare_bones tutorial, but I'm having some issues getting it to run in Virtualbox. Initially, my makefile was:
"make" yielded:
I therefore changed the "compile" target to:
This compiles fine, but trying to load "floppy.img" in Virtualbox gives a VERR_VD_RAW_INVALID_HEADER error. Any help getting this to load properly? For reference, "uname -a" gives "Linux XXXX 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:09:38 UTC 2010 x86_64 GNU/Linux"
I'm following the http://wiki.osdev.org/Bare_bones tutorial, but I'm having some issues getting it to run in Virtualbox. Initially, my makefile was:
Code: Select all
make : compile
dd if=/dev/zero of=pad bs=1 count=750
cat boot/stage1 boot/stage2 pad kernel.bin > floppy.img
compile :
nasm -f elf -o loader.o loader.s
gcc -o kernel.o -c kernel.c -Wall -Wextra -Werror -nostdlib -fno-builtin -nostartfiles -nodefaultlibs
ld -T linker.ld -o kernel.bin loader.o kernel.o
Code: Select all
nasm -f elf -o loader.o loader.s
gcc -o kernel.o -c kernel.c -Wall -Wextra -Werror -nostdlib -fno-builtin -nostartfiles -nodefaultlibs
ld -T linker.ld -o kernel.bin loader.o kernel.o
ld: i386 architecture of input file `loader.o' is incompatible with i386:x86-64 output
make: *** [compile] Error 1
Code: Select all
compile :
nasm -f elf64 -o loader.o loader.s
gcc -m64 -o kernel.o -c kernel.c -Wall -Wextra -Werror -nostdlib -fno-builtin -nostartfiles -nodefaultlibs
ld -m elf_x86_64 -T linker.ld -o kernel.bin loader.o kernel.o