Эх сурвалжийг харах

feat(gblibc): add __stack_chk_fail_local

greatbridf 2 жил өмнө
parent
commit
f3ad9758aa
1 өөрчлөгдсөн 15 нэмэгдсэн , 0 устгасан
  1. 15 0
      gblibc/src/errno.c

+ 15 - 0
gblibc/src/errno.c

@@ -1,5 +1,20 @@
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
 int* __errno_location(void)
 {
     static int __errno = 0;
     return &__errno;
 }
+
+void
+__attribute__((noreturn))
+__attribute__((visibility("hidden")))
+__stack_chk_fail_local(void)
+{
+    const char* msg = "***** stack overflow detected *****\n"
+                      "quiting...\n";
+    write(STDERR_FILENO, msg, strlen(msg));
+    exit(-1);
+}