summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Yun <justinyun@google.com>2017-05-23 16:30:43 +0900
committerJustin Yun <justinyun@google.com>2017-05-24 14:21:24 +0900
commitc571709b287469bea052b4618d3b119ff1794883 (patch)
tree03f8c1de356e7553411bd36202e8953cfa976c0b
parent13f562865f67b33e663caa042d4ee619ad1b45f2 (diff)
downloadlibhardware-c571709b287469bea052b4618d3b119ff1794883.tar.gz
libhardware: load with dlopen if the library is in system.
Originally, it is not allowed to open non-sphal libraries if the device has sphal namespace. However, some system processes are still using libhardware to load non-sphal libraries. Since it has no harm to allow system libraries to be loaded by libhardware, this patch loads the library from the default namespace if the library is located in system partition. Bug: 38435840 Test: sailfish builds and boots Change-Id: I206da11a2656559fcd0995d32dbd73621a79a683
-rw-r--r--hardware.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/hardware.c b/hardware.c
index 37b61c44..8faac074 100644
--- a/hardware.c
+++ b/hardware.c
@@ -82,7 +82,14 @@ static int load(const char *id,
* dlopen returns. Since RTLD_GLOBAL is not or'd in with
* RTLD_NOW the external symbols will not be global
*/
- handle = android_load_sphal_library(path, RTLD_NOW);
+ if (strncmp(path, "/system/", 8) == 0) {
+ /* If the library is in system partition, no need to check
+ * sphal namespace. Open it with dlopen.
+ */
+ handle = dlopen(path, RTLD_NOW);
+ } else {
+ handle = android_load_sphal_library(path, RTLD_NOW);
+ }
if (handle == NULL) {
char const *err_str = dlerror();
ALOGE("load: module=%s\n%s", path, err_str?err_str:"unknown");