@@ -17,7 +17,7 @@ constexpr char DYNAMIC_MODULES_SEARCH_PATH[] = "ENVOY_DYNAMIC_MODULES_SEARCH_PAT
1717
1818absl::StatusOr<DynamicModulePtr>
1919newDynamicModule (const std::filesystem::path& object_file_absolute_path, const bool do_not_close,
20- const bool load_globally) {
20+ const bool load_globally) {
2121 // From the man page of dlopen(3):
2222 //
2323 // > This can be used to test if the object is already resident (dlopen() returns NULL if it
@@ -31,15 +31,10 @@ newDynamicModule(const std::filesystem::path& object_file_absolute_path, const b
3131 // loaded module. We don't need to call the init function again.
3232 return std::make_unique<DynamicModule>(handle);
3333 }
34+ // RTLD_LOCAL is always needed to avoid collisions between multiple modules.
3435 // RTLD_LAZY is required for not only performance but also simply to load the module, otherwise
3536 // dlopen results in Invalid argument.
36- int mode = RTLD_LAZY;
37- if (load_globally) {
38- mode |= RTLD_GLOBAL;
39- } else {
40- // RTLD_LOCAL is used by default to avoid collisions between multiple modules.
41- mode |= RTLD_LOCAL;
42- }
37+ int mode = RTLD_LOCAL | RTLD_LAZY;
4338 if (do_not_close) {
4439 mode |= RTLD_NODELETE;
4540 }
@@ -65,9 +60,9 @@ newDynamicModule(const std::filesystem::path& object_file_absolute_path, const b
6560 absl::StrCat (" Failed to initialize dynamic module: " , object_file_absolute_path.c_str ()));
6661 }
6762 // Checks the kAbiVersion and the version of the dynamic module.
68- if (absl::string_view (abi_version) != absl::string_view (AbiVersion:: kAbiVersion )) {
69- return absl::InvalidArgumentError (absl::StrCat ( " ABI version mismatch: got " , abi_version,
70- " , but expected " , AbiVersion:: kAbiVersion ));
63+ if (absl::string_view (abi_version) != absl::string_view (kAbiVersion )) {
64+ return absl::InvalidArgumentError (
65+ absl::StrCat ( " ABI version mismatch: got " , abi_version, " , but expected " , kAbiVersion ));
7166 }
7267 return dynamic_module;
7368}
0 commit comments