diff --git a/libnativeloader/include/nativeloader/native_loader.h b/libnativeloader/include/nativeloader/native_loader.h index d606a760e..2a6aaec50 100644 --- a/libnativeloader/include/nativeloader/native_loader.h +++ b/libnativeloader/include/nativeloader/native_loader.h @@ -43,6 +43,9 @@ void* OpenNativeLibrary(JNIEnv* env, jobject class_loader, jstring library_path); +__attribute__((visibility("default"))) +bool CloseNativeLibrary(void* handle); + #if defined(__ANDROID__) // Look up linker namespace by class_loader. Returns nullptr if // there is no namespace associated with the class_loader. diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index baad197fe..8cf140e03 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -255,6 +255,10 @@ void* OpenNativeLibrary(JNIEnv* env, #endif } +bool CloseNativeLibrary(void* handle) { + return dlclose(handle) == 0; +} + #if defined(__ANDROID__) android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader) { std::lock_guard guard(g_namespaces_mutex);