Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!wuarchive!cs.utexas.edu!bcm!rice!rice!sun-spots-request From: auspex!guy@uunet.uu.net (Guy Harris) Newsgroups: comp.sys.sun Subject: Re: dlopen broken? Keywords: Miscellaneous Message-ID: <1990Aug9.022250.7092@rice.edu> Date: 7 Aug 90 18:00:18 GMT Sender: sun-spots-request@rice.edu Organization: Sun-Spots Lines: 28 Approved: Sun-Spots@rice.edu Originator: spots@titan.rice.edu X-Sun-Spots-Digest: Volume 9, Issue 296, message 10 X-Refs: Original: v9n296 >Is the program interface to the dynamic linker (dlopen) broken? If "dlopen()" drops core, it's pretty much by definition broken. Unfortunately, I don't know what the fix is. However, you are making what may be another error in your sample code: > symbol = "_p2"; > symAdr = dlsym(handle,symbol); > printf("returned symbol address of %s is %x\n",symbol,symAdr); > (*symAdr)(); Presumably, the function "_p2()" is defined as _p2() { ... } in the ".so" file you've loaded. If it's "p2()", not "_p2()", you should hand "p2", not "_p2", to "dlsym". The loader may happen to let you get away with sticking the underscore in front of it, but you're not supposed to put it there, the fact that in Sun's C implementation on non-386-based machines the compiler sticks an underscore there nonwithstanding. Not all C implementations put the underscore there, and if the second argument to "dlsym()" were supposed to have the underscore there iff the C implementation puts it there, portability would be blown out of the water (remember, S5R4 has "dlopen()", too, and most S5R4 implementations probably won't put the underscore there).