From c32004713dcc6ad8a1bb335d7cbd340f4d1a2479 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 7 Oct 2021 18:46:59 -0400 Subject: [PATCH] Use RTLD_DEEPBIND for loading plugins with dlopen() on Linux. --- src/plugin.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugin.cpp b/src/plugin.cpp index e16f3793..ac371625 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -58,7 +58,12 @@ static void* loadLibrary(std::string libraryPath) { // Change it back when we're finished DEFER({system::setWorkingDirectory(cwd);}); // Load library with dlopen - void* handle = dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); + void* handle = NULL; + #if defined ARCH_LIN + handle = dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_DEEPBIND); + #elif defined ARCH_MAC + handle = dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); + #endif if (!handle) throw Exception("Failed to load library %s: %s", libraryPath.c_str(), dlerror()); #endif