Index: configure.in
===================================================================
RCS file: /cvs/gnome/glib/configure.in,v
retrieving revision 1.396
diff -u -r1.396 configure.in
--- configure.in	17 Mar 2004 19:07:37 -0000	1.396
+++ configure.in	17 Apr 2004 10:07:21 -0000
@@ -1003,6 +1003,7 @@
 dnl G_MODULE_IMPL= don't reset, so cmd-line can override
 G_MODULE_NEED_USCORE=0
 G_MODULE_BROKEN_RTLD_GLOBAL=0
+G_MODULE_BROKEN_DLOPEN_NULL=0
 G_MODULE_HAVE_DLERROR=0
 dnl *** force native WIN32 shared lib loader 
 if test -z "$G_MODULE_IMPL"; then
@@ -1091,6 +1092,37 @@
 	else
   		G_MODULE_BROKEN_RTLD_GLOBAL=0
 	fi
+dnl *** check for NetBSD's dlopen(NULL, 0) brokenness
+	AC_CACHE_CHECK([for DLOPEN(NULL, 0) brokenness],
+		glib_cv_dlopennull_broken,[
+		AC_TRY_RUN([
+#include <dlfcn.h>
+#ifndef RTLD_GLOBAL
+#  define RTLD_GLOBAL 0
+#endif
+#ifndef RTLD_LAZY
+#  define RTLD_LAZY 0
+#endif
+int gettext;
+int main () {
+    void *handle;
+    handle = dlopen ("libintl.so", RTLD_GLOBAL | RTLD_LAZY);
+    if (!handle) return 0;
+    handle = dlopen (NULL, 0);
+    if (!handle) return 0;
+    handle = dlsym (handle, "gettext");
+    return handle == NULL;
+}                       ],
+			[glib_cv_dlopennull_broken=no],
+			[glib_cv_dlopennull_broken=yes],
+			[glib_cv_dlopennull_broken=no])
+		rm -f plugin.c plugin.o plugin.lo
+	])
+	if test "x$glib_cv_dlopennull_broken" = "xyes"; then
+  		G_MODULE_BROKEN_DLOPEN_NULL=1
+	else
+  		G_MODULE_BROKEN_DLOPEN_NULL=0
+	fi
 dnl *** check whether we need preceeding underscores
 	AC_CACHE_CHECK([for preceeding underscore in symbols],
 		glib_cv_uscore,[
@@ -1156,6 +1188,7 @@
 AC_SUBST(G_MODULE_LDFLAGS)
 AC_SUBST(G_MODULE_HAVE_DLERROR)
 AC_SUBST(G_MODULE_BROKEN_RTLD_GLOBAL)
+AC_SUBST(G_MODULE_BROKEN_DLOPEN_NULL)
 AC_SUBST(G_MODULE_NEED_USCORE)
 AC_SUBST(GLIB_DEBUG_FLAGS)
 
Index: gmodule/gmodule.c
===================================================================
RCS file: /cvs/gnome/glib/gmodule/gmodule.c,v
retrieving revision 1.45
diff -u -r1.45 gmodule.c
--- gmodule/gmodule.c	22 Feb 2004 01:31:24 -0000	1.45
+++ gmodule/gmodule.c	17 Apr 2004 10:07:23 -0000
@@ -521,6 +521,24 @@
   return g_static_private_get (&module_error_private);
 }
 
+static void
+g_module_symbol_aux (GModule		*module,
+		     const gchar	*symbol_name,
+		     gpointer		*symbol)
+{
+#ifdef	G_MODULE_NEED_USCORE
+  {
+    gchar *name;
+
+    name = g_strconcat ("_", symbol_name, NULL);
+    *symbol = _g_module_symbol (module->handle, name);
+    g_free (name);
+  }
+#else	/* !G_MODULE_NEED_USCORE */
+  *symbol = _g_module_symbol (module->handle, symbol_name);
+#endif	/* !G_MODULE_NEED_USCORE */
+}
+
 gboolean
 g_module_symbol (GModule	*module,
 		 const gchar	*symbol_name,
@@ -538,17 +556,28 @@
   
   g_static_rec_mutex_lock (&g_module_global_lock);
 
-#ifdef	G_MODULE_NEED_USCORE
+#ifdef	G_MODULE_BROKEN_DLOPEN_NULL
+  if (module == main_module)
   {
-    gchar *name;
-
-    name = g_strconcat ("_", symbol_name, NULL);
-    *symbol = _g_module_symbol (module->handle, name);
-    g_free (name);
+      g_module_symbol_aux(module, symbol_name, symbol);
+      if (*symbol == NULL)
+        {
+          for (module = modules; module; module = module->next)
+            {
+              g_module_symbol_aux(module, symbol_name, symbol);
+              if (*symbol != NULL)
+                {
+                  g_module_set_error (NULL);
+                  break;
   }
-#else	/* !G_MODULE_NEED_USCORE */
-  *symbol = _g_module_symbol (module->handle, symbol_name);
-#endif	/* !G_MODULE_NEED_USCORE */
+            }
+        }
+    }
+  else
+    g_module_symbol_aux(module, symbol_name, symbol);
+#else	/* !G_MODULE_BROKEN_DLOPEN_NULL */
+  g_module_symbol_aux(module, symbol_name, symbol);
+#endif	/* G_MODULE_BROKEN_DLOPEN_NULL */
   
   module_error = g_module_error ();
   if (module_error)
Index: gmodule/gmoduleconf.h.in
===================================================================
RCS file: /cvs/gnome/glib/gmodule/gmoduleconf.h.in,v
retrieving revision 1.9
diff -u -r1.9 gmoduleconf.h.in
--- gmodule/gmoduleconf.h.in	22 Feb 2004 01:31:24 -0000	1.9
+++ gmodule/gmoduleconf.h.in	17 Apr 2004 10:07:23 -0000
@@ -45,6 +45,9 @@
 #if	(@G_MODULE_BROKEN_RTLD_GLOBAL@)
 #define G_MODULE_BROKEN_RTLD_GLOBAL
 #endif
+#if	(@G_MODULE_BROKEN_DLOPEN_NULL@)
+#define G_MODULE_BROKEN_DLOPEN_NULL
+#endif
 
 #ifdef __cplusplus
 }
