comparison Core/SharedLibrary.cpp @ 3696:b7087f928050

use of RTLD_DEEPBIND in dlopen() while loading plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 Feb 2020 11:16:35 +0100
parents 94f4a18a79cc
children 626d5f4a5afb
comparison
equal deleted inserted replaced
3694:9107cca846b6 3696:b7087f928050
60 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError(); 60 LOG(ERROR) << "LoadLibrary(" << path_ << ") failed: Error " << ::GetLastError();
61 throw OrthancException(ErrorCode_SharedLibrary); 61 throw OrthancException(ErrorCode_SharedLibrary);
62 } 62 }
63 63
64 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__) 64 #elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__OpenBSD__)
65 handle_ = ::dlopen(path_.c_str(), RTLD_NOW); 65
66 /**
67 * "RTLD_LOCAL" is the default, and is only present to be
68 * explicit. "RTLD_DEEPBIND" was added in Orthanc 1.6.0, in order
69 * to avoid crashes while loading plugins from the LSB binaries of
70 * the Orthanc core.
71 **/
72 #if defined(RTLD_DEEPBIND) // This is a GNU extension
73 handle_ = ::dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
74 #else
75 handle_ = ::dlopen(path_.c_str(), RTLD_NOW | RTLD_LOCAL);
76 #endif
77
66 if (handle_ == NULL) 78 if (handle_ == NULL)
67 { 79 {
68 std::string explanation; 80 std::string explanation;
69 const char *tmp = ::dlerror(); 81 const char *tmp = ::dlerror();
70 if (tmp) 82 if (tmp)