--- atexit.c.orig Thu Mar 11 13:16:53 2004 +++ atexit.c Mon Mar 15 12:47:39 2004 @@ -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);