My tools:
- Ubuntu 10.04 LTS
- GCC version 4.4.3 (a 2009 build)
- GNU Binutils 2.20.1-system.20100303; GNU gold 1.9 (seems to replace LD or is a different version of it; objdump confirms everything it outputs is correct)
- GNU Make 3.81
- NASM 2.07 ("compiled on Nov 5 2009")
Here's how the kernel gets compiled:
Code: Select all
nasm -felf32 -o obj/start.o src/arch/x86-32/start.asm
gcc -O2 -fexpensive-optimizations -fomit-frame-pointer -I./inc/ -Wall -pedantic -nostdinc -nostdlib -fno-builtin -fno-stack-protector -masm=intel -m32 -c -o obj/kmain.o src/kmain.c
ld -b elf32-i386 --oformat elf32-i386 -Tsrc/arch/x86-32/kernel.ld -o bin/kernel obj/start.o obj/kmain.o
Code: Select all
; 32-bit mode
bits 32
; Multiboot Flags
MBF_PAGE_ALIGN equ 0x01
MBF_MEMORY_INFO equ 0x02
; Multiboot Magic
MBB_HEADER equ 0x1BADB002
; Kernel Multiboot Fields
KMB_FLAGS equ (MBF_PAGE_ALIGN|MBF_MEMORY_INFO)
KMB_CHECKSUM equ -(MBB_HEADER+KMB_FLAGS)
; Globals and Externals here omitted, globals : start, multiboot; externals : code, bsss, end, kmain;
; Multiboot header
multiboot:
; Setup the multiboot header
dd MBB_HEADER
dd KMB_FLAGS
dd KMB_CHECKSUM
; Flags does not include A.OUT kludge; I've tried this with and without the kludge and the flag (and combinations of them)
; Start of the program (marked as the entry point in the linker script)
start:
; Code here is irrelevant. It first disables interrupts, sets up the stack, calls the kernel with the multiboot structure address passed, and finally halts processor execution
; NOTE: OBJDUMP confirms that the multiboot header is at the 1st megabyte of memory, exactly.
Code: Select all
void kmain(void *pMultiboot)
{
if (!pMultiboot)
return;
}
Thanks in advance for the time you take to read this, and especially any thought that goes into my issues.
Cheers,
-Aaron