--- atexit.c.orig 2004-03-11 13:16:53.000000000 -0800 +++ atexit.c 2004-09-15 00:14:26.000000000 -0700 @@ -45,6 +45,9 @@ #include <stdlib.h> #include <unistd.h> #include <pthread.h> +#if defined(__DYNAMIC__) +#include <mach-o/dyld.h> +#endif /* defined(__DYNAMIC__) */ #include "atexit.h" #include "un-namespace.h" @@ -125,7 +128,11 @@ fn.fn_type = ATEXIT_FN_STD; fn.fn_ptr.std_func = func;; fn.fn_arg = NULL; +#if defined(__DYNAMIC__) + fn.fn_dso = (void *)_dyld_get_image_header_containing_address((unsigned long) func); +#else /* ! defined(__DYNAMIC__) */ fn.fn_dso = NULL; +#endif /* defined(__DYNAMIC__) */ error = atexit_register(&fn); return (error); @@ -156,7 +163,7 @@ * handlers are called. */ void -__cxa_finalize(void *dso) +__cxa_finalize(const void *dso) { struct atexit *p; struct atexit_fn fn;