dlopen/dlclose issue
Ian Lance Taylor
iant@google.com
Thu Aug 23 21:10:00 GMT 2012
On Thu, Aug 23, 2012 at 2:51 AM, Alexander Smirnov
<Alexander.Smirnov@siemens.com> wrote:
>
> I've faced with problem and spent too much to find a solution, but without
> success. So hope, somebody can advise me here, thanks in advance.
>
> 1. My demo application:
> I wrote simple shared object with one function which prints something to the
> screen. I compiled it by: gcc -shared -o libtest.so test.c
>
> In other file I opened this library by 'dlopen(..., RTLD_LAZY)'. Than found
> sym by dlsym, executed it and called dlclose.
>
> 2. After 'dlclose' I executed dlopen(..., RTLD_LAZY | RTLD_NOLOAD) and it
> returned non-zero value. So the library is still in use!
>
> 3. If I call dlclose twice, the point 2 returns 0.
>
>
> What is the proper way to check if some library loaded/unloaded? Why do I
> need to call dlclose twice? Why in some applications 'while(dlclose(...) ==
> 0);' loop can be infinite?
I don't know the answer to your question. I do know that it has
nothing to do with GCC. You are asking a question about the
implementation of dlopen and dlclose, but they are not part of GCC.
If you are using a GNU/Linux system, then they are part of glibc. I
don't know if there is a glibc help group.
You could try setting LD_DEBUG=all in the environment before running
your program, and see if that tells you anything useful.
Ian
More information about the Gcc-help
mailing list