#include <stdarg.h>
#include <pthread.h>
#include <Availability.h>
+#include <mach-o/dyld_priv.h>
-#include "mach-o/dyld_priv.h"
#include "dyldLibSystemInterface.h"
+
extern void _ZN4dyld3logEPKcz(const char*, ...);
extern struct LibSystemHelpers* _ZN4dyld17gLibSystemHelpersE;
char* __cxa_get_globals()
{
// if libSystem.dylib not yet initialized, or is old libSystem, use shared global
- if ( (_ZN4dyld17gLibSystemHelpersE == NULL) || (_ZN4dyld17gLibSystemHelpersE->version < 5) )
+ if ( (_ZN4dyld17gLibSystemHelpersE == NULL) || (_ZN4dyld17gLibSystemHelpersE->version < 7) )
return sPreMainCxaGlobals;
if ( sCxaKey == 0 ) {
// we don't need a lock because only one thread can be in dyld at a time
_ZN4dyld17gLibSystemHelpersE->pthread_key_create(&sCxaKey, &free);
}
- char* data = (char*)pthread_getspecific(sCxaKey);
+ char* data = (char*)_ZN4dyld17gLibSystemHelpersE->pthread_getspecific(sCxaKey);
if ( data == NULL ) {
- data = calloc(2,sizeof(void*));
+ long* t = (long*)calloc(2,sizeof(long));
+ data = (char*)t;
_ZN4dyld17gLibSystemHelpersE->pthread_setspecific(sCxaKey, data);
}
return data;
char* __cxa_get_globals_fast()
{
// if libSystem.dylib not yet initialized, or is old libSystem, use shared global
- if ( (_ZN4dyld17gLibSystemHelpersE == NULL) || (_ZN4dyld17gLibSystemHelpersE->version < 5) )
+ if ( (_ZN4dyld17gLibSystemHelpersE == NULL) || (_ZN4dyld17gLibSystemHelpersE->version < 7) )
return sPreMainCxaGlobals;
- return pthread_getspecific(sCxaKey);
+ return _ZN4dyld17gLibSystemHelpersE->pthread_getspecific(sCxaKey);
}
-
-#if !__arm__
+#if !__USING_SJLJ_EXCEPTIONS__
//
-// The intel versions of dyld uses zero-cost exceptions which are handled by
-// linking with a special copy of libunwind.a
+// When dyld uses zero-cost exceptions it just needs to implement
+// _dyld_find_unwind_sections to return sections inside dyld proper.
//
extern void* ehStart __asm("section$start$__TEXT$__eh_frame");
}
}
-#endif // !__arm__
-
-
-#if __arm__
+#else
+//
+// When dyld uses setjump-longjump exceptions it needs to implement
+// routines to push and pop a stack of _Unwind_FunctionContext.
+//
struct _Unwind_FunctionContext
{