For a library loaded by a shared object, how do I allow versioned symbols to be resolved by the executable?

There is a proprietary library used by many executables on a system which has a bug in one routine we need to patch across the whole system. This makes something like LD_PRELOAD cumbersome and impractical to try to force into every environment these executables might be launched from. So the plan given to me was to copy say libspecial.so to libspecial.so.org and create a new library named libspecial.so which overrides that one function and is linked with libspecial.so.org to allow all the remaining symbols to be loaded automatically.

In a small test with a little example library this worked fine.
The one function is overridden, and all the other symbols in the original library are available to the main executable transparently.

However the library in question has some versioned symbols. For some reason this information does not get passed through, and the executable complains (well, the run time linker) that it cannot lookup the needed version information.

How can I allowed versioned symbols to be resolved by the executable?
Maybe if I explicitly load the library with dlopen are there some special flags to allow this?
Or is there an easier way?

A colleague suggested we could resort to stripping all version needed information from the executable ELF structures, which we tried and it works. But then I need to change all executables, and there's also the worry this could break something so feels too risky. Since the run time linker can handle resolving the symbols and is just getting hung up on passing through the version information, I'm hoping I'm just missing a way to easily handle this in the library.

  • I wasn't aware of dlmopen(). Along with LM_ID_BASE this sounds like exactly what I want. However that doesn't work either. I don't really understand why. I have a feeling there is a larger lesson about the details of run time linking I need to learn here. – BuddyJohn Sep 30 '16 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.