If dlopen() fails, retry with everything stripped after .so
https://bugzilla.mozilla.org/show_bug.cgi?id=650772
Index: nspr/pr/src/linking/prlink.c
--- nspr/pr/src/linking/prlink.c.orig
+++ nspr/pr/src/linking/prlink.c
@@ -7,6 +7,10 @@
 
 #include <string.h>
 
+#if defined(OPENBSD)
+#include <limits.h> /* for PATH_MAX */
+#endif
+
 #ifdef XP_UNIX
 #  ifdef USE_DLFCN
 #    include <dlfcn.h>
@@ -384,6 +388,7 @@ PR_LoadLibrary(const char* name) {
 ** map first.
 */
 static PRLibrary* pr_LoadLibraryByPathname(const char* name, PRIntn flags) {
+  PR_LOG(_pr_linker_lm, PR_LOG_ALWAYS, ("[PID=%d] pr_LoadLibraryByPathname(%s,%d)", getpid(), name, flags));
   PRLibrary* lm;
   PRLibrary* result = NULL;
   PRInt32 oserr;
@@ -478,6 +483,10 @@ static PRLibrary* pr_LoadLibraryByPathname(const char*
 #      else
     int dl_flags = 0;
 #      endif
+#      if defined(OPENBSD)
+    char sname[PATH_MAX];
+    char *c;
+#      endif
     void* h = NULL;
 #      if defined(DARWIN)
     PRBool okToLoad = PR_FALSE;
@@ -529,6 +538,18 @@ static PRLibrary* pr_LoadLibraryByPathname(const char*
     }
 #      else
     h = dlopen(name, dl_flags);
+#        if defined(OPENBSD)
+    /* On OpenBSD, we don't know what can be major.minor in libfoo.so.major.minor */
+    /* but ld.so is smart enough to open the correct lib when asked for libfoo.so */
+    /* so if the previous dlopen() failed, let's strip what's after .so and retry */
+    strncpy(sname, name, PATH_MAX);
+    if (!h) {
+        if ((c = strstr(sname,".so")) != NULL)
+            c[3] = '\0';
+        h = dlopen(sname, dl_flags);
+    }
+    PR_LOG(_pr_linker_lm, PR_LOG_ALWAYS, ("[PID=%d] pr_LoadLibraryByPathname dlopen(%s) returned %p", getpid(), name, h));
+#        endif
 #      endif
 #    elif defined(USE_HPSHL)
     int shl_flags = 0;
@@ -558,7 +579,11 @@ static PRLibrary* pr_LoadLibraryByPathname(const char*
       PR_DELETE(lm);
       goto unlock;
     }
+#    if defined(OPENBSD)
+    lm->name = strdup(sname);
+#    else
     lm->name = strdup(name);
+#    endif
     lm->dlh = h;
     lm->next = pr_loadmap;
     pr_loadmap = lm;
