Home:ALL Converter>Load shared library for another shared library

Load shared library for another shared library

Ask Time:2018-11-14T23:21:14         Author:Jan Schatz

Json Formatter

I am working on an update application that must be able to run on an existing system and is also started by another application on this existing system.

I am using a shared library that itself uses OpenSSL, but didn't link against it. Previously my update application linked against OpenSSL to work around this. But now I cannot link against OpenSSL any longer due to binary incompatibilities. Now when my application is started on the existing system, I get an undefined symbol error, because OpenSSL is not loaded. Note that I don't have the option to load it through LD_PRELOAD, because I cannot change the application that starts my update application.

I thought about loading OpenSSL through dlopen hoping that the shared library would be able to use it. But the shared library uses OpenSSL in a C constructor (__attribute__((constructor (101))) void myConstructor()) and even if I call dlopen inside another constructor with higher priority, the dynamic loader already seems to have searched (and failed) for OpenSSL. My constructor is not even being executed.

LD_BIND_NOW is not set, so I wonder why the undefined symbol error occurs before my constructor is being called.

Author:Jan Schatz,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/53303474/load-shared-library-for-another-shared-library
yy