misc/libphysfs/platform_macosx.c
branchwebgl
changeset 9197 e4e366013e9a
parent 9183 4cd7c7aafea7
child 10017 de822cd3df3a
--- a/misc/libphysfs/platform_macosx.c	Sun Jun 16 00:46:11 2013 +0400
+++ b/misc/libphysfs/platform_macosx.c	Mon Jun 17 16:56:58 2013 +0200
@@ -44,6 +44,31 @@
     fflush(stderr);
     abort();
 }
+
+
+/* apparently libssp is missing from 10.4 SDK
+   code from http://wiki.osdev.org/GCC_Stack_Smashing_Protector */
+void * __stack_chk_guard = NULL;
+
+void __stack_chk_guard_setup()
+{
+    unsigned char * p;
+    p = (unsigned char *) &__stack_chk_guard;
+
+    /* If you have the ability to generate random numbers in your kernel then use them,
+       otherwise for 32-bit code: *p = 0x00000aff; */
+    *p = random();
+}
+
+void __attribute__((noreturn)) __stack_chk_fail()
+{
+    /* put your panic function or similar in here */
+    unsigned char * vid = (unsigned char *)0xB8000;
+    vid[1] = 7;
+    for(;;)
+    vid[0]++;
+}
+
 #endif
 #endif /* __APPLE__ */