# HG changeset patch # User koda # Date 1370901692 -7200 # Node ID 4cd7c7aafea7768f0904aeaee79f6810d5dd2565 # Parent db48ce61653142e33dad908289d2603b90153c7c libssp (required by stack-protector) is not available on 10.4 diff -r db48ce616531 -r 4cd7c7aafea7 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__ */