$OpenBSD: patch-j2se_src_solaris_hpi_src_linker_md_c,v 1.1 2007/09/06 15:46:19 kurt Exp $
--- j2se/src/solaris/hpi/src/linker_md.c.orig	Thu Jul  5 05:03:37 2007
+++ j2se/src/solaris/hpi/src/linker_md.c	Fri Jul 27 18:25:14 2007
@@ -45,12 +45,6 @@
 #endif
 
 /*
- * This lock protects the dl wrappers, assuring that two threads aren't
- * in libdl at the same time.
- */
-sys_mon_t _dl_lock;
-
-/*
  * glibc-2.0 libdl is not MT safe.  If you are building with any glibc,
  * chances are you might want to run the generated bits against glibc-2.0
  * libdl.so, so always use locking for any version of glibc.
@@ -66,7 +60,15 @@ sys_mon_t _dl_lock;
     #define NEED_DL_LOCK
 #endif
 
+#ifdef NEED_DL_LOCK
 /*
+ * This lock protects the dl wrappers, assuring that two threads aren't
+ * in libdl at the same time.
+ */
+sys_mon_t _dl_lock;
+#endif
+
+/*
  * create a string for the JNI native function name by adding the
  * appropriate decorations.
  */
@@ -102,7 +104,7 @@ sysBuildLibName(char *holder, int holderlen, char *pna
 }
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     static int thr_main(void)
     {
         return -1;
@@ -120,10 +122,10 @@ sysLoadLibrary(const char *name, char *err_buf, int er
 
 #ifdef NEED_DL_LOCK
     sysMonitorEnter(sysThreadSelf(), &_dl_lock);
-    result = dlopen(name, RTLD_NOW);
+    result = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
     sysMonitorExit(sysThreadSelf(), &_dl_lock);
 #else
-    result = dlopen(name, RTLD_LAZY);
+    result = dlopen(name, RTLD_LAZY|RTLD_GLOBAL);
 #endif
     /*
      * This is a bit of bulletproofing to catch the commonly occurring
