diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-09-11 03:29:34 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-09-11 03:29:34 +0000 |
commit | 9a40e1d8a49701bbdb234f5376053aca753531be (patch) | |
tree | 1d044a6226f8ee616ae8cdc08884436f9f69feca | |
parent | eb0a4fbb625ba846fbb0c7434d0d0da5de6a0bb9 (diff) | |
parent | 0140ccbf64f366cbe9e535ad90bec42ab79c993b (diff) | |
download | rs-ndk-sysroot-r21.tar.gz |
Merge "Let RS support lib to load shared object without absolute path."ndk-sysroot-r21
-rw-r--r-- | cpu_ref/rsCpuExecutable.cpp | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/cpu_ref/rsCpuExecutable.cpp b/cpu_ref/rsCpuExecutable.cpp index 87c791a9..63008ba1 100644 --- a/cpu_ref/rsCpuExecutable.cpp +++ b/cpu_ref/rsCpuExecutable.cpp @@ -207,27 +207,39 @@ void* SharedLibraryUtils::loadSharedLibrary(const char *cacheDir, // location for shared libraries first. loaded = loadSOHelper(scriptSOName.c_str(), cacheDir, resName, alreadyLoaded); - if (loaded == nullptr) { - ALOGE("Unable to open shared library (%s): %s", - scriptSOName.c_str(), dlerror()); + if (loaded != nullptr) { + return loaded; + } + ALOGE("Unable to open shared library (%s): %s", scriptSOName.c_str(), dlerror()); #ifdef RS_COMPATIBILITY_LIB - // One final attempt to find the library in "/system/lib". - // We do this to allow bundled applications to use the compatibility - // library fallback path. Those applications don't have a private - // library path, so they need to install to the system directly. - // Note that this is really just a testing path. - std::string scriptSONameSystem("/system/lib/librs."); - scriptSONameSystem.append(resName); - scriptSONameSystem.append(".so"); - loaded = loadSOHelper(scriptSONameSystem.c_str(), cacheDir, - resName); - if (loaded == nullptr) { - ALOGE("Unable to open system shared library (%s): %s", - scriptSONameSystem.c_str(), dlerror()); - } -#endif + // Re-trying without absolute path. + // For RS support lib, the shared object may not be extracted from the apk. + // In order to access that, we need to load the library without specifying + // the absolute path. + std::string scriptSONameApk("librs."); + scriptSONameApk.append(resName); + scriptSONameApk.append(".so"); + loaded = loadSOHelper(scriptSONameApk.c_str(), cacheDir, resName); + if (loaded != nullptr) { + return loaded; } + ALOGE("Unable to open APK shared library (%s): %s", scriptSONameApk.c_str(), dlerror()); + + // One final attempt to find the library in "/system/lib". + // We do this to allow bundled applications to use the compatibility + // library fallback path. Those applications don't have a private + // library path, so they need to install to the system directly. + // Note that this is really just a testing path. + std::string scriptSONameSystem("/system/lib/librs."); + scriptSONameSystem.append(resName); + scriptSONameSystem.append(".so"); + loaded = loadSOHelper(scriptSONameSystem.c_str(), cacheDir, resName); + if (loaded == nullptr) { + ALOGE("Unable to open system shared library (%s): %s", + scriptSONameSystem.c_str(), dlerror()); + } +#endif return loaded; } @@ -295,10 +307,12 @@ void* SharedLibraryUtils::loadSOHelper(const char *origName, const char *cacheDi void *loaded = nullptr; +#ifndef RS_COMPATIBILITY_LIB // Skip everything if we don't even have the original library available. if (access(origName, F_OK) != 0) { return nullptr; } +#endif // RS_COMPATIBILITY_LIB // Common path is that we have not loaded this Script/library before. if (LoadedLibraries.find(origName) == LoadedLibraries.end()) { |