$OpenBSD: patch-jdk_src_solaris_native_sun_security_pkcs11_j2secmod_md_c,v 1.1 2008/03/19 18:05:46 kurt Exp $
--- jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c.orig	Tue Dec  4 04:05:47 2007
+++ jdk/src/solaris/native/sun/security/pkcs11/j2secmod_md.c	Thu Feb 14 18:04:01 2008
@@ -34,6 +34,11 @@
 
 #include "j2secmod.h"
 
+#ifndef RTLD_NOLOAD
+/* A gross hack that will work if the NSS library is only opened once */
+static void *nssLibHandle = NULL;
+#endif
+
 void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) {
     void *hModule = (void*)jHandle;
     void *fAddress = dlsym(hModule, functionName);
@@ -51,7 +56,11 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmo
 {
     const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL);
     // look up existing handle only, do not load
+#ifdef RTLD_NOLOAD
     void *hModule = dlopen(libName, RTLD_NOLOAD);
+#else
+    void *hModule = nssLibHandle;
+#endif
     dprintf2("-handle for %s: %u\n", libName, hModule);
     (*env)->ReleaseStringUTFChars(env, jLibName, libName);
     return (jlong)hModule;
@@ -65,6 +74,9 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmo
 
     dprintf1("-lib %s\n", libName);
     hModule = dlopen(libName, RTLD_LAZY);
+#ifndef RTLD_NOLOAD
+    nssLibHandle = hModule;
+#endif
     (*env)->ReleaseStringUTFChars(env, jLibName, libName);
     dprintf2("-handle: %u (0X%X)\n", hModule, hModule);
 
