fix(main): _start 加 stackrealign,修复变参函数 movaps #GP

根因链:_start 由 bootloader jmp 进入(rsp≡0 mod 16),编译器/llc 按 call
约定对齐函数帧(假设入口 rsp≡8 mod 16)→ 帧整体偏 8 → _start 内所有调用
rsp≡8 mod 16 → __init__ 的 float 变参调用(snprintf %.2f 保存 xmm)movaps
#GP(cr4.OSFXSR 已启用、地址 16 对齐仍 #GP 正是此因)。

加 t.attr.stackrealign 使 _start 序言动态重对齐栈,与入口约定无关。
This commit is contained in:
TermiNexus committed 2026-08-26 20:18:09 +08:00
1 parent ff802c2eed
commit 61208676c6
1 file changed
+3 -1
+3 -1
View File
@@ -395,7 +395,9 @@ class ViperKernel:
VKP: ViperKernel | t.CPtr
@c.Attribute(t.attr.section(".text.startup"), t.attr.aligned(16))
# stackrealign:_start 由 bootloader jmp 进入(rsp≡0 mod 16),llc 按 call 约定
# 假设入口 rsp≡8 → 帧偏 8 → 变参函数 movaps #GP。动态重对齐栈修复。
@c.Attribute(t.attr.section(".text.startup"), t.attr.aligned(16), t.attr.stackrealign)
def _start() -> t.CInt:
global VKP, BootInfo
saved_rdi: t.CUnsignedLong