This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dynamic loading of two libraries in linux


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]