我找到了一个简单内核加载程序的示例,并试图了解它是如何工作的。但由于错误,我甚至无法构建它:
loader.s:5:20: error: unexpected token in '.section' directive
.section .multiboot
^
loader.s:11:15: error: unexpected token in '.section' directive
.section .text
^
loader.s:28:1: error: unknown directive
.sectio .bss
以下是加载程序代码:
.set MAGIC, 0x1badb002
.set FLAGS, (1<<0 | 1<<1)
.set CHECKSUM, -(MAGIC + FLAGS)
.section .multiboot
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .text
.extern main
.extern callConstructors
.global loader
loader:
mov $kernel_stack, %esp
call callConstructors
push %eax
push %ebx
call main
_stop:
cli
hlt
jmp _stop
.sectio .bss
.space 2*1024*1024;
kernel_stack:
我把它编译成
as -m32 loader.s
.
搜索之后我发现我不需要使用
.section
具有
.text
和
.bss
但我不知道
.multiboot
.多引导
附笔。