diff --git a/module_manager/native_module_manager.cpp b/module_manager/native_module_manager.cpp index cef6799ba906bd976819494cdc0c0a8e792d96a6..7d9323994a64fdbe06cef063ac6c6ca703b94766 100755 --- a/module_manager/native_module_manager.cpp +++ b/module_manager/native_module_manager.cpp @@ -15,6 +15,7 @@ #include "native_module_manager.h" +#include #include #include @@ -25,6 +26,8 @@ #include "securec.h" #include "utils/log.h" +#define NDK "ndk" + namespace { constexpr static int32_t NATIVE_PATH_NUMBER = 2; } // namespace @@ -240,20 +243,30 @@ void NativeModuleManager::CreateLdNamespace(const std::string moduleName, const !defined(LINUX_PLATFORM) Dl_namespace current_ns; Dl_namespace ns; + Dl_namespace ndk_ns; + std::string nsName = "arkUI_" + moduleName; dlns_init(&ns, nsName.c_str()); dlns_get(nullptr, ¤t_ns); + dlns_get(NDK, &ndk_ns); dlns_create2(&ns, lib_ld_path, 0); if (!sharedLibsSonames_) { CreateSharedLibsSonames(); } dlns_inherit(&ns, ¤t_ns, sharedLibsSonames_); + + // valid ndk_ns + if (strlen(ndk_ns.name) > 0) { + dlns_inherit(&ns, &ndk_ns, nullptr); + } nsMap_[moduleName] = ns; + nsMap_[NDK] = ndk_ns; HILOG_INFO("CreateLdNamespace success, path: %{private}s", lib_ld_path); #endif } -void NativeModuleManager::SetAppLibPath(const std::string& moduleName, const std::vector& appLibPath) +void NativeModuleManager::SetAppLibPath(const std::string& moduleName, const std::vector& appLibPath, + const bool &isSystemApp) { char* tmp = new char[NAPI_PATH_MAX]; errno_t err = EOK; @@ -286,7 +299,9 @@ void NativeModuleManager::SetAppLibPath(const std::string& moduleName, const std } appLibPathMap_[moduleName] = tmp; - CreateLdNamespace(moduleName, tmp); + if (isSystemApp) { + CreateLdNamespace(moduleName, tmp); + } HILOG_INFO("create ld namespace, path: %{private}s", appLibPathMap_[moduleName]); } diff --git a/module_manager/native_module_manager.h b/module_manager/native_module_manager.h index fbd004e9fc50198aa2ab4d8ece135540c9221cdc..819c003f0f26ab00552ab980571c001a885bc107 100644 --- a/module_manager/native_module_manager.h +++ b/module_manager/native_module_manager.h @@ -67,7 +67,8 @@ public: static uint64_t Release(); void Register(NativeModule* nativeModule); - void SetAppLibPath(const std::string& moduleName, const std::vector& appLibPath); + void SetAppLibPath(const std::string& moduleName, const std::vector& appLibPath, + const bool &isSystemApp = false); NativeModule* LoadNativeModule(const char* moduleName, const char* path, bool isAppModule, bool internal = false); void SetNativeEngine(std::string moduleName, NativeEngine* nativeEngine);