libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dlopen from dlopend library question


From: Gleb Natapov
Subject: Re: dlopen from dlopend library question
Date: Mon, 1 Aug 2005 17:58:03 +0300

On Mon, Aug 01, 2005 at 03:42:17PM +0200, Ralf Wildenhues wrote:
> Hi Gleb,
> 
> Sorry for the late response,
> 
Thank you for you response!

> * Gleb Natapov wrote on Sun, Jul 17, 2005 at 11:39:34AM CEST:
> > 
> > I have library (lets say liba.so) that on startup checks available 
> > hardware and loads appropriate plugin (say plugin.so) to drive the hardware.
> > plugin.so uses symbols from liba.so. 
> > 
> > Everything works OK if liba.so linked with application, but if
> > application is modular by itself and use module (say module.so) that
> > is linked with liba.so then dlopen of plugin.so from liba.so fails with
> > unresolved symbols.
> > 
> > How can I solve this issue?
> 
> If you use Libtool/libltdl for portable modules (which you do not seem
> to do), look at Libtool branch-2-0 or CVS HEAD, which allows ltdlopen'ing
> from libraries.  Make sure to read the corresponding documentation
> pertaining to libltdl, make use of `-module' and `-export-dynamic'.
> 
The project I saw this problem with actually use libtool (not 2.0
though). And both flags are used.

> > PS: All this happens using linux system.
> 
> If you want to be GCC/GNU ld specific only, you can use --export-dynamic
> for exporting symbols to dlopen'ed modules.
> 
> If this is not enough help, don't hesitate to ask for details.  If you
> could provide a small example that reproduces the failure, the better.
> 
After investigation of the problem I found that liba.so tries to load
plugin.so from library constructor. Even if liba.so is dlopen with 
RTLD_GLOBAL flag set, plugin.so can't resolve symbols from liba.so

Let me explain this one more time.

Program 'prog' calls dlopen(liba.so, RTLD_GLOBAL), in constructor liba.so
calls dlopen(plugin.so) and this call fails with unresolved symbols
from liba.so.

If we add function init_a() to liba.so and move dlopen(plugin.so) from 
constructor to the function and we call this function from 'prog' after
dlopen (liba.so, RTLD_GLOBAL) then everything works as expected.

--
                        Gleb.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]