su 1 年之前
父節點
當前提交
f179f81b89
共有 2 個文件被更改,包括 44 次插入0 次删除
  1. 2 0
      src/platform/x86_64/nr.rs
  2. 42 0
      toolchain.sh

+ 2 - 0
src/platform/x86_64/nr.rs

@@ -26,3 +26,5 @@ pub const SYS_KILL: usize = 23;
 pub const SYS_SIGACTION: usize = 24;
 pub const SYS_RT_SIGRETURN: usize = 25;
 pub const SYS_GETPID: usize = 26;
+pub const SYS_DUP: usize=28;
+pub const SYS_DUP2: usize=29;

+ 42 - 0
toolchain.sh

@@ -0,0 +1,42 @@
+# 当前脚本用于初始化自定义的Rust工具链
+if [ -z "$(which cargo)" ]; then
+    echo "尚未安装Rust,请先安装Rust"
+    exit 1
+fi
+
+DRAGONOS_UNKNOWN_ELF_PATH=$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-dragonos
+mkdir -p ${DRAGONOS_UNKNOWN_ELF_PATH}/lib
+# 设置工具链配置文件
+echo   \
+"{\
+    \"arch\": \"x86_64\",
+    \"code-model\": \"kernel\",
+    \"cpu\": \"x86-64\",
+    \"os\": \"dragonos\",
+    \"target-endian\": \"little\",
+    \"target-pointer-width\": \"64\",
+    \"target-c-int-width\": \"32\",
+    \"data-layout\": \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128\",
+    \"disable-redzone\": true,
+    \"features\": \"-3dnow,-3dnowa,-avx,-avx2\",
+    \"linker\": \"rust-lld\",
+    \"linker-flavor\": \"ld.lld\",
+    \"llvm-target\": \"x86_64-unknown-none\",
+    \"max-atomic-width\": 64,
+    \"panic-strategy\": \"abort\",
+    \"position-independent-executables\": true,
+    \"relro-level\": \"full\",
+    \"stack-probes\": {
+      \"kind\": \"inline-or-call\",
+      \"min-llvm-version-for-inline\": [
+        16,
+        0,
+        0
+      ]
+    },
+    \"static-position-independent-executables\": true,
+    \"supported-sanitizers\": [
+      \"kcfi\"
+    ],
+    \"target-pointer-width\": \"64\"
+}" > ${DRAGONOS_UNKNOWN_ELF_PATH}/target.json || exit 1