diff options
author | Yifan Hong <elsk@google.com> | 2017-11-09 13:08:18 -0800 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2017-11-10 13:19:37 -0800 |
commit | 1ccdb7d92aeda49ecd3d668cb7dce8dee40a4e0a (patch) | |
tree | 3e53dfce5f5c6a974da5f5f03d839597f46261ce /libvndksupport | |
parent | 6707ef139d9786887649e3e3c2e3e251a95dc96d (diff) | |
download | system_core-1ccdb7d92aeda49ecd3d668cb7dce8dee40a4e0a.tar.gz system_core-1ccdb7d92aeda49ecd3d668cb7dce8dee40a4e0a.tar.bz2 system_core-1ccdb7d92aeda49ecd3d668cb7dce8dee40a4e0a.zip |
libvndksupport: do not use functions from android/dlext.h
... if they are not available. Use weak symbols and do not call the
following functions when they are not defined:
* android_dlopen_ext
* android_get_exported_namespace
Test: links
Test: boots
Change-Id: I653548bac61a0eba001f72bab969b5b858bd1553
Diffstat (limited to 'libvndksupport')
-rw-r--r-- | libvndksupport/linker.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libvndksupport/linker.c b/libvndksupport/linker.c index d06cafc8e..bc5620b93 100644 --- a/libvndksupport/linker.c +++ b/libvndksupport/linker.c @@ -21,7 +21,8 @@ #define LOG_TAG "vndksupport" #include <log/log.h> -extern struct android_namespace_t* android_get_exported_namespace(const char*); +__attribute__((weak)) extern struct android_namespace_t* android_get_exported_namespace(const char*); +__attribute__((weak)) extern void* android_dlopen_ext(const char*, int, const android_dlextinfo*); static const char* namespace_name = NULL; @@ -31,7 +32,9 @@ static struct android_namespace_t* get_vendor_namespace() { if (vendor_namespace == NULL) { int name_idx = 0; while (namespace_names[name_idx] != NULL) { - vendor_namespace = android_get_exported_namespace(namespace_names[name_idx]); + if (android_get_exported_namespace != NULL) { + vendor_namespace = android_get_exported_namespace(namespace_names[name_idx]); + } if (vendor_namespace != NULL) { namespace_name = namespace_names[name_idx]; break; @@ -48,7 +51,10 @@ void* android_load_sphal_library(const char* name, int flag) { const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = vendor_namespace, }; - void* handle = android_dlopen_ext(name, flag, &dlextinfo); + void* handle = NULL; + if (android_dlopen_ext != NULL) { + handle = android_dlopen_ext(name, flag, &dlextinfo); + } if (!handle) { ALOGE("Could not load %s from %s namespace: %s.", name, namespace_name, dlerror()); } |