diff -aurN dlcompat-20030629.orig/dlfcn.c dlcompat-20030629/dlfcn.c
--- dlcompat-20030629.orig/dlfcn.c	Mon Jun 23 23:13:21 2003
+++ dlcompat-20030629/dlfcn.c	Tue Sep 23 23:19:11 2003
@@ -164,7 +164,7 @@
 static void resetdlerror(void);
 static const struct mach_header *my_find_image(const char *name);
 static const struct mach_header *image_for_address(const void *address);
-static void dlcompat_cleanup(void);
+/* static void dlcompat_cleanup(void); */
 static inline const char *dyld_error_str(void);
 
 #if FINK_BUILD
@@ -451,7 +451,7 @@
 {
 	if (dls)
 	{
-		if (dls->module == MAGIC_DYLIB_MOD && !isFlagSet(mode, RTLD_GLOBAL))
+		if (dls->module == MAGIC_DYLIB_MOD && isFlagSet(mode, RTLD_LOCAL))
 		{
 			warning("trying to open a .dylib with RTLD_LOCAL");
 			error("unable to open a .dylib with RTLD_LOCAL");
@@ -699,7 +699,7 @@
 		case NSObjectFileImageInappropriateFile:
 			if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage)
 			{
-				if (!isFlagSet(mode, RTLD_GLOBAL))
+				if (isFlagSet(mode, RTLD_LOCAL))
 				{
 					warning("trying to open a .dylib with RTLD_LOCAL");
 					error("unable to open this file with RTLD_LOCAL");
@@ -812,12 +812,13 @@
 		if (pthread_key_create(&dlerror_key, &dlerrorfree))
 			exit(1);
 		/* And be neat and tidy and clean up after ourselves */	
-		atexit(dlcompat_cleanup);
+		/* atexit(dlcompat_cleanup); */
+                /* This does not work, we can not guarantee the order atexit functions will be called */
 	}
 }
 
 #pragma CALL_ON_LOAD dlcompat_init_func
-
+/*
 static void dlcompat_cleanup(void)
 {
 	struct dlstatus *dls;
@@ -839,7 +840,7 @@
 		free(dls);
 	}
 }
-
+*/
 static void resetdlerror()
 {
 	struct dlthread *tss;