From c2f3a219c7e13fd549b6529bb1158895074ef8ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 11:47:41 +0000 Subject: [PATCH 1/6] Initial plan From b6812ae748ea131406ef480089376d811764fda1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 11:49:18 +0000 Subject: [PATCH 2/6] Consolidate Cargo config: Add kernel/x86_64-rint.json target and unstable section to root config, remove kernel/.cargo/config.toml Co-authored-by: mackz-maxw <61910211+mackz-maxw@users.noreply.github.com> --- .cargo/config.toml | 13 ++++++++++++- kernel/.cargo/config.toml | 16 ---------------- 2 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 kernel/.cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml index f08e10e..017ca4a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,5 +14,16 @@ rustflags = [ linker = "ld.lld" rustflags = ["-C", "link-arg=-nostartfiles"] +[target."kernel/x86_64-rint.json"] +rustflags = [ + "-C", "link-arg=-Tkernel/ld/link.ld", + "-C", "relocation-model=static", + "-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 From 149cc6b24312d17b049f341fbb2428ea71bfed70 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 11:59:24 +0000 Subject: [PATCH 3/6] Add code-model=kernel to support high memory linker script Co-authored-by: mackz-maxw <61910211+mackz-maxw@users.noreply.github.com> --- .cargo/config.toml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 017ca4a..67b3aa6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,10 +14,27 @@ rustflags = [ linker = "ld.lld" rustflags = ["-C", "link-arg=-nostartfiles"] +[target.x86_64-rint] +rustflags = [ + "-C", "link-arg=-Tkernel/ld/link.ld", + "-C", "relocation-model=static", + "-C", "code-model=kernel", + "-C", "no-redzone=yes", +] + +[target."x86_64-rint.json"] +rustflags = [ + "-C", "link-arg=-Tkernel/ld/link.ld", + "-C", "relocation-model=static", + "-C", "code-model=kernel", + "-C", "no-redzone=yes", +] + [target."kernel/x86_64-rint.json"] rustflags = [ "-C", "link-arg=-Tkernel/ld/link.ld", "-C", "relocation-model=static", + "-C", "code-model=kernel", "-C", "no-redzone=yes", ] From ae88282d280c7e2d3fd5edb1aa4c34cb741265c8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 12:00:52 +0000 Subject: [PATCH 4/6] Simplify config: remove duplicate target sections Co-authored-by: mackz-maxw <61910211+mackz-maxw@users.noreply.github.com> --- .cargo/config.toml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 67b3aa6..46766b6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -22,22 +22,6 @@ rustflags = [ "-C", "no-redzone=yes", ] -[target."x86_64-rint.json"] -rustflags = [ - "-C", "link-arg=-Tkernel/ld/link.ld", - "-C", "relocation-model=static", - "-C", "code-model=kernel", - "-C", "no-redzone=yes", -] - -[target."kernel/x86_64-rint.json"] -rustflags = [ - "-C", "link-arg=-Tkernel/ld/link.ld", - "-C", "relocation-model=static", - "-C", "code-model=kernel", - "-C", "no-redzone=yes", -] - [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" From 368fb8289914a38edc7a8d3616a0a8eb78a36476 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 12:01:49 +0000 Subject: [PATCH 5/6] Add documentation comments to kernel target configuration Co-authored-by: mackz-maxw <61910211+mackz-maxw@users.noreply.github.com> --- .cargo/config.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 46766b6..60aede9 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,11 +14,17 @@ 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 kernel/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", ] From a62c94032a9be277015bd8590e769216dc2118dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 12:02:59 +0000 Subject: [PATCH 6/6] Fix misleading comment about target specification Co-authored-by: mackz-maxw <61910211+mackz-maxw@users.noreply.github.com> --- .cargo/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 60aede9..6048004 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -15,7 +15,7 @@ linker = "ld.lld" rustflags = ["-C", "link-arg=-nostartfiles"] # Custom target for x86_64 kernel with higher-half memory layout -# Used when building with --target kernel/x86_64-rint.json +# Used when building with --target x86_64-rint.json [target.x86_64-rint] rustflags = [ # Linker script for higher-half kernel (0xFFFFFFFF80000000)