浏览代码

Add stack_chk functionality

Jeremy Soller 6 年之前
父节点
当前提交
9fc785dcc6
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 2 0
      build.rs
  2. 10 0
      src/c/stack_chk.c

+ 2 - 0
build.rs

@@ -13,7 +13,9 @@ fn main() {
         .flag("-fno-stack-protector")
         .file("src/c/dlmalloc.c")
         .file("src/c/fcntl.c")
+        .file("src/c/stack_chk.c")
         .file("src/c/stdio.c")
+        .file("src/c/unistd.c")
         .compile("relibc_c");
 
     println!("cargo:rustc-link-lib=static=relibc_c");

+ 10 - 0
src/c/stack_chk.c

@@ -0,0 +1,10 @@
+#include <stdint.h>
+
+void abort();
+
+uintptr_t __stack_chk_guard = 0xd048c37519fcadfe;
+
+__attribute__((noreturn))
+void __stack_chk_fail(void) {
+	abort();
+}