diff --git a/.cargo/config.toml b/.cargo/config.toml index f08e10e..6048004 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,5 +14,23 @@ rustflags = [ linker = "ld.lld" rustflags = ["-C", "link-arg=-nostartfiles"] +# Custom target for x86_64 kernel with higher-half memory layout +# Used when building with --target x86_64-rint.json +[target.x86_64-rint] +rustflags = [ + # Linker script for higher-half kernel (0xFFFFFFFF80000000) + "-C", "link-arg=-Tkernel/ld/link.ld", + # Static relocation model for bare-metal kernel + "-C", "relocation-model=static", + # Kernel code model required for high memory addresses (> 4GB) + "-C", "code-model=kernel", + # Disable red zone for interrupt safety + "-C", "no-redzone=yes", +] + [target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" \ No newline at end of file +linker = "aarch64-linux-gnu-gcc" + +[unstable] +build-std = ["core", "compiler_builtins", "alloc"] +build-std-features = ["compiler-builtins-mem"] \ No newline at end of file diff --git a/kernel/.cargo/config.toml b/kernel/.cargo/config.toml deleted file mode 100644 index 8db733e..0000000 --- a/kernel/.cargo/config.toml +++ /dev/null @@ -1,16 +0,0 @@ -[build] -target = "x86_64-rint.json" - -[target."x86_64-rint.json"] -rustflags = [ - # 关键:脚本路径相对于 kernel 包根目录 - "-Clink-arg=-Tld/link.ld", - # 建议:静态重定位,避免产生不适合内核的绝对寻址/PLT - "-C", "relocation-model=static", - "-C", "no-redzone=yes", -] - - -[unstable] -build-std = ["core", "compiler_builtins", "alloc"] -build-std-features = ["compiler-builtins-mem"] \ No newline at end of file