04-19-2006 09:16 PM
While starting of the application, it will load some .sl(for example a.sl, b.sl, c.sl etc) files using shl_load.
In the middle of the application, I will once again try to load a.sl and b.sl and get some information and will close. This we are doing with dlopen() and dlclose().
As far as i know , if we try to load shared library file which is already loaded, again it will not load the library but it will increase the reference count. This behaviour is in solaris. Is the Same behaviour for HP-UX?
When trying to do dlclose(), a.sl is still there in memory but b.sl is unloaded completely. But this is not happening on the solaris, both shared libraries are still present. Our requirement is in HP-UX also both libraries should be present.
Can anyone tell me why this is happening? Do i need to specify any special flags?
Quick response is appreciated.
04-19-2006 10:46 PM
>>A successful invocation of dlclose does not guarantee that the objects associated with handle have actually been removed from the address space of the process. Objects loaded by one invocation of dlopen may also be loaded by another invocation of dlopen. The same object may also be opened multiple times. An object is not removed from the address space until all references to that object through an explicit dlopen invocation have been closed and all other objects implicitly referencing that object have also been closed.
>>Once an object has been closed by dlclose, referencing symbols contained in that object can cause undefined behavior.
Also, can I assume you are using the -ldl flag with the compiler or with the loader?
live free or die
harry d brown jr
04-20-2006 02:23 AM
Whether i have to compile the application with -ldl or compile the shared library(a.sl) with -ldl?
Application is not compiled with -ldl.
But if i want to compile what is the path of libdl.sl file?
04-21-2006 03:51 AM
you should add
to the linker commandline for all executables or shared objects calling dlopen().
In Solaris (as in HP-UX or Linux) you get a handle after with a successful call to dlopen - even when opening the same more than once.
Using a (once) valid handle after a dlcose() may succeed, when another handle of the same shared object is open. But you won't do that.neither in Solaris or HP-UX.