$OpenBSD: patch-dynl_c,v 1.2 2009/01/21 18:30:16 kili Exp $
--- dynl.c.orig	Thu Jan 31 02:48:03 2008
+++ dynl.c	Sat Nov 29 15:26:11 2008
@@ -400,7 +400,23 @@ SCM l_dyn_call(symb, shl)
   ASRTER(NIMP(symb) && STRINGP(symb), symb, ARG1, s_call);
   ASRTER(NIMP(shl) && CAR(shl)==tc16_shl, shl, ARG2, s_call);
   DEFER_INTS;
-  func = dlsym(SHL(shl), CHARS(symb));
+#ifdef __OpenBSD__
+# ifndef __ELF__
+  {
+  char *n;
+
+  n = malloc(LENGTH(symb)+2);
+  if (n) {
+  	*n = '_';
+	strcpy(n+1, CHARS(symb));
+	func = dlsym(SHL(shl), n);
+	free(n);
+  }
+  }
+# endif
+#endif
+  if (!func)
+        func = dlsym(SHL(shl), CHARS(symb));
   if (!func) {
     char *dlr = dlerror();
     ALLOW_INTS;
@@ -429,7 +445,23 @@ SCM l_dyn_main_call(symb, shl, args)
   ASRTER(NIMP(symb) && STRINGP(symb), symb, ARG1, s_main_call);
   ASRTER(NIMP(shl) && CAR(shl)==tc16_shl, shl, ARG2, s_main_call);
   DEFER_INTS;
-  func = dlsym(SHL(shl), CHARS(symb));
+#ifdef __OpenBSD__
+# ifndef __ELF__
+  {
+  char *n;
+
+  n = malloc(LENGTH(symb)+2);
+  if (n) {
+  	*n = '_';
+	strcpy(n+1, CHARS(symb));
+	func = dlsym(SHL(shl), n);
+	free(n);
+  }
+  }
+# endif
+#endif
+  if (!func)
+        func = dlsym(SHL(shl), CHARS(symb));
   if (!func) {
     char *dlr = dlerror();
     ALLOW_INTS;
