dlopen broken?

Guy Harris auspex!guy at uunet.uu.net
Wed Aug 8 04:00:18 AEST 1990


>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).



More information about the Comp.sys.sun mailing list