Subject: dlopen(),dlsym(),... problems
To: None <>
From: None <>
List: port-pmax
Date: 08/06/1998 14:03:06
Is there a special trick to make dlopen(), dlsym(),... work on the pmax
port?  The reason I'm asking is I'm finishing up a package for scilab-2.4
(a powerful, matlab like scientific computation environment) and one of
the features is the ability to dynamically, on the fly, link C and/or
FORTRAN routines into the program (for speed critical items).  Anyway, I
have it all working on i386 and mac68k platforms, but not the pmax
(DECstation 5000/200, NetBSD-1.3.1).  Basically dlopen() fails. 

To work on this in a simpler environment (instead of a _huge_ program),
I've been trying the following test code:

/* externals.c */
double myfn(double x,double y)
  double z;

  z = x+y-3.0;

/* end of externals.c */


% cc -O2 -Wall -c externals.c
% ld -Bshareable externals.o -o ext_lib

then the test program:
/* dl_tst.c */

#include <stdio.h>
#include <dlfcn.h>

  void *hd1 = (void *) 0;
  hd1 = dlopen("ext_lib", RTLD_NOW);
  printf("dlopen returned %d\n",hd1);

  if ( (hd1 == (void *) NULL) || (hd1 < (void *) 0) ) 
    printf("dlerror() is: %s\r\n",dlerror());

/* end of dl_tst.c */

cc -O2 -Wall -o dl_tst dl_tst.c

% ./dl_tst

dlopen returned 0
dlerror() is: (null)

When I try this on i386 (NetBSD-1.3.2) or mac68k (NetBSD-1.3) I get
something more like:

dlopen returned 1073824000

and then subsequent calls to dlsym() succeed (in the i386 and mac68k

I'm assuming this has something to do with ELF vs. a.out, but I'm pretty
much in over my head in terms of understanding that stuff.  Any pointers
would be greatly appreciated.

If anyone wants to try this out,  the file

has everything (a Makefile and the 2 c programs) to reproduce my problems.
The c code in that archive has just a few more printf's to help me debug