The system boots fine if I don't call the _init & _fini functions, but if I call them (I've got the proper files linked, and the constructors themselves seem to work/be called) the magic number becomes 0xFFFFFFFF. As far as i looked, the assembly code doesn't seem to be touching either of the (eax and ebx) registers.
crti.s
Code: Select all
.section .init
.global _init
.type _init, @function
_init:
push %ebp
movl %esp, %ebp
.section .fini
.global _fini
.type _fini, @function
_fini:
push %ebp
movl %esp, %ebp
crtn.s
Code: Select all
.section .init
popl %ebp
ret
.section .fini
popl %ebp
ret
Code: Select all
.set MAGIC, 0x1BADB002
.set FLAGS, (1<<0) | (1<<1)
.set CHECKSUM, -(MAGIC + FLAGS)
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .bss
.align 16
stack_bottom: #16kb stack
.skip 16384
stack_top:
.section .text
.global _start
.type _start, @function
_start:
mov $stack_top, %esp
call _init
pushl %eax
pushl %ebx
call kernel_main #push magic & multiboot struct and call main
call _fini
cli
hang:
hlt
jmp hang
.size _start, . - _start