[Python-bugs-list] [Bug #119483] OpenBSD can't dynamically load modules

noreply@sourceforge.net noreply@sourceforge.net
Fri, 10 Nov 2000 10:56:02 -0800


Bug #119483, was updated on 2000-Oct-26 14:11
Here is a current snapshot of the bug.

Project: Python
Category: Core
Status: Closed
Resolution: Duplicate
Bug Group: Platform-specific
Priority: 5
Summary: OpenBSD can't dynamically load modules

Details: 
On OpenBSD, one always gets a traceback trying to import a '.so' module (replacing blahblahblah with module name):

ImportError: dynamic module does not define init function (initblahblahblah)

The problem is that dynload_shlib.c doesn't prepend an underscore to the symbol name (the C standard for naming function exports). Some OS's will try both the name with and without the underscore, some try only the literal symbol name when calling dlsym. OpenBSD requires the literal symbol. Hence, the following patch is in order:

--- dynload_shlib.c    Thu Oct 26 11:10:36 2000
+++ dynload_shlib.c     Thu Oct 26 11:10:51 2000
@@ -55,7 +55,7 @@
        }
 
        /* ### should there be a leading underscore for some platforms? */
-       sprintf(funcname, "init%.200s", shortname);
+       sprintf(funcname, "_init%.200s", shortname);
 
        if (fp != NULL) {
                int i;


Follow-Ups:

Date: 2000-Oct-26 14:15
By: gvanrossum

Comment:
This was reported before. I just fixed this 1-2 days ago in the CvS tree.
-------------------------------------------------------

Date: 2000-Nov-10 10:56
By: none

Comment:
This is a problem with a.out versions of NetBSD also.
However, the ELF versions of NetBSD can use the __ELF__
define to manage the problem. here is a patchfile which handles both a.out and ELF versions of NetBSD:

--- dynload_shlib.c.org Wed Nov  8 20:01:21 2000
+++ dynload_shlib.c     Wed Nov  8 20:38:49 2000
@@ -55,7 +55,11 @@
        }
 
        /* ### should there be a leading underscore for some platforms? */
-       sprintf(funcname, "init%.200s", shortname);
+#ifndef __ELF__
+       sprintf(funcname, "_init%.200s", shortname);
+#else
+        sprintf(funcname, "init%.200s", shortname);
+#endif
 
        if (fp != NULL) {
                int i;

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=119483&group_id=5470