libssp (required by stack-protector) is not available on 10.4
authorkoda
Tue, 11 Jun 2013 00:01:32 +0200
changeset 9183 4cd7c7aafea7
parent 9181 db48ce616531
child 9185 115e7daa4796
libssp (required by stack-protector) is not available on 10.4
misc/libphysfs/platform_macosx.c
--- a/misc/libphysfs/platform_macosx.c	Tue Jun 11 01:40:55 2013 +0300
+++ b/misc/libphysfs/platform_macosx.c	Tue Jun 11 00:01:32 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__ */