dynamic loading on SunOS 4.1

Jose M. Pereira (pereira@cocaina.inesc.pt)
Thu, 3 Feb 94 16:51:10 +0100

> I've had a number of complaints about using shared libraries on SunOS
> 4.1. I now believe that this is caused by the GNU loader which
> doesn't handle shared libraries. The configure script detects the
> presence of <dlfnc.h> and tells the import.c file, which then attempts
> to use shared libraries.

GNU ld (gcc >=2.x.x) does handle shared libraries on SunOS 4.1(3?).

> Would the people who have these problems be so kind to try out the
> following (yes *unofficial*) patch to configure and Python/import.c?
> It adds a test for the dlopen() function and turns on use of shared
> libraries only if that exists as well. Let me know if it works!

I'm not sure what those complaints might be, but I did find that import.c
broke between 1.0.0beta and the official release. (See below the offending
code). I thought that

#ifndef RTLD_NOW
#define RTLD_NOW 2
#endif

was a nice, undocumented (at least in <dlfcn.h>) feature of 4.1.3 dlopen().
The problem is, it simply does not work ("dlopen: invalid mode") in my
installation (sparc10, SunOs 4.1.3). The old RTLD_LAZY (1) works like a charm.

diff -c Python/import.c~ Python/import.c
*** Python/import.c~ Wed Jan 12 10:53:19 1994
--- Python/import.c Tue Feb 1 12:09:05 1994
***************
*** 308,314 ****
{
/* RTLD_NOW: resolve externals now
(i.e. core dump now if some are missing) */
! void *handle = dlopen(namebuf, RTLD_NOW);
if (handle == NULL) {
err_setstr(ImportError, dlerror());
return NULL;
--- 308,315 ----
{
/* RTLD_NOW: resolve externals now
(i.e. core dump now if some are missing) */
! /*JMP void *handle = dlopen(namebuf, RTLD_NOW); */
! void *handle = dlopen(namebuf, RTLD_LAZY);
if (handle == NULL) {
err_setstr(ImportError, dlerror());
return NULL;