dlopen, RTLD_LOCAL and identically named libraries

Mark Boorer markboo99@gmail.com
Thu Aug 28 15:54:00 GMT 2014


Hi,

I have a question regarding dlopen with RTLD_LOCAL and libraries with
identical names

I have two versions of a library with the same filename in separate
directories, and I have two separate "plugins", each linking to one
version of the library.

plugin1.so -> library1/library.so
plugin2.so -> library2/library.so

The path to library.so is baked into the RPATH of each plugin, so when
ran independently, they each call the correct functions. However, when
I load both plugins one after the other (with RTLD_NOW | RTLD_LOCAL) ,
only the first version of library.so is used.

The behaviour is the same if the two versions of library.so share an
soname as well. It seems as though the basename of the library (or the
soname) is checked at a global level.
I would expect that behaviour if library.so was already linked in the
global scope, but in my case it is not.

Is this the intended behaviour? I would have thought that RTLD_LOCAL
would start the library search afresh.

I have a small example C application that demonstrates the issue if required.

Any help/advice would be greatly appreciated :)

Cheers,
Mark



More information about the Libc-help mailing list