This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Dynamic loading of two libraries in linux
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Not provided <krzysiek dot kwiatkowski at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Tue, 28 Jun 2011 09:12:30 -0400
- Subject: Re: Dynamic loading of two libraries in linux
- References: <BANLkTikgWns=CQMTwCdYfsNRmCQSH9E6DA@mail.gmail.com>
On Mon, Jun 27, 2011 at 6:22 PM, Not provided
<krzysiek.kwiatkowski@gmail.com> wrote:
> Step1. load old-library
> Step2. routing setup
> ..... service is available and at one point I find a the bug ....
> Step3. load new-version of library with a bugfix (long process)
> Step4. remove routing for old-library (quick)
> Step5. setup routing for new-library (quick)
> Step6. unload old-library
My understanding of the ELF resolution rules and the implementation in
glibc is that technically unloading a library is fraught with
problems, but we've made it work because it's a useful paradigm for
plugin development.
As long as there are no dependencies from the application to the DSO,
in the form of relocations, then you should be fine to unload the
library and load a new version.
You might want to try running with LD_BIND_NOW and LD_DEBUG=all to
ensure that no other libraries end up resolving relocations to your
newly loaded library since that would prevent you from unloading it.
As always if you switch to C++ code, then this gets more complicated
as the dependency tree gets more complicated if not impossible to
solve and impossible to unload the shared library safely (think of
static objects with constructors and destructors that must run at
program exit, yes this is somewhat ameliorated by special gcc options
but it's a hack).
Cheers,
Carlos.