summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-04-22 10:33:06 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-04-22 10:33:07 +0000
commit16f6429c38c24236418cf127a4c11c5d8a2fd47b (patch)
tree23a414e3ab87424087cf58b9d063cd59974b5a82 /linker
parentf3489807af6d48f208bc796d3c9b0d83a4fd5374 (diff)
parent012cb4583a5f8564059142bb1900ea3a31e7cfa9 (diff)
downloadbionic-16f6429c38c24236418cf127a4c11c5d8a2fd47b.zip
bionic-16f6429c38c24236418cf127a4c11c5d8a2fd47b.tar.gz
bionic-16f6429c38c24236418cf127a4c11c5d8a2fd47b.tar.bz2
Merge "Add android_dlopen_ext() interface to linker."
Diffstat (limited to 'linker')
-rw-r--r--linker/dlfcn.cpp29
-rwxr-xr-xlinker/linker.cpp6
-rw-r--r--linker/linker.h3
3 files changed, 25 insertions, 13 deletions
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 6e70808..0292bdf 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -20,6 +20,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <android/dlext.h>
#include <bionic/pthread_internal.h>
#include "private/bionic_tls.h"
@@ -64,9 +65,10 @@ void android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
do_android_update_LD_LIBRARY_PATH(ld_library_path);
}
-void* dlopen(const char* filename, int flags) {
+void* android_dlopen_ext(const char* filename, int flags, const android_dlextinfo* extinfo)
+{
ScopedPthreadMutexLocker locker(&gDlMutex);
- soinfo* result = do_dlopen(filename, flags);
+ soinfo* result = do_dlopen(filename, flags, extinfo);
if (result == NULL) {
__bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
return NULL;
@@ -74,6 +76,10 @@ void* dlopen(const char* filename, int flags) {
return result;
}
+void* dlopen(const char* filename, int flags) {
+ return android_dlopen_ext(filename, flags, NULL);
+}
+
void* dlsym(void* handle, const char* symbol) {
ScopedPthreadMutexLocker locker(&gDlMutex);
@@ -168,15 +174,15 @@ int dlclose(void* handle) {
}
#if defined(__arm__)
- // 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888888888899999 9999900000000001 1
- // 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012345678901234 5678901234567890 1
+ // 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888888888899999 9999900000000001 1111111112222222222 333333333344444444445
+ // 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012345678901234 5678901234567890 1234567890123456789 012345678901234567890
# define ANDROID_LIBDL_STRTAB \
- "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0android_get_LD_LIBRARY_PATH\0dl_iterate_phdr\0dl_unwind_find_exidx\0"
+ "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0android_get_LD_LIBRARY_PATH\0dl_iterate_phdr\0android_dlopen_ext\0dl_unwind_find_exidx\0"
#elif defined(__aarch64__) || defined(__i386__) || defined(__mips__) || defined(__x86_64__)
- // 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888888888899999 9999900000000001 1
- // 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012345678901234 5678901234567890 1
+ // 0000000 00011111 111112 22222222 2333333 3333444444444455555555556666666 6667777777777888888888899999 9999900000000001 1111111112222222222
+ // 0123456 78901234 567890 12345678 9012345 6789012345678901234567890123456 7890123456789012345678901234 5678901234567890 1234567890123456789
# define ANDROID_LIBDL_STRTAB \
- "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0android_get_LD_LIBRARY_PATH\0dl_iterate_phdr\0"
+ "dlopen\0dlclose\0dlsym\0dlerror\0dladdr\0android_update_LD_LIBRARY_PATH\0android_get_LD_LIBRARY_PATH\0dl_iterate_phdr\0android_dlopen_ext\0"
#else
# error Unsupported architecture. Only arm, arm64, mips, mips64, x86 and x86_64 are presently supported.
#endif
@@ -195,8 +201,9 @@ static ElfW(Sym) gLibDlSymtab[] = {
ELFW(SYM_INITIALIZER)( 36, &android_update_LD_LIBRARY_PATH, 1),
ELFW(SYM_INITIALIZER)( 67, &android_get_LD_LIBRARY_PATH, 1),
ELFW(SYM_INITIALIZER)( 95, &dl_iterate_phdr, 1),
+ ELFW(SYM_INITIALIZER)(111, &android_dlopen_ext, 1),
#if defined(__arm__)
- ELFW(SYM_INITIALIZER)(111, &dl_unwind_find_exidx, 1),
+ ELFW(SYM_INITIALIZER)(130, &dl_unwind_find_exidx, 1),
#endif
};
@@ -213,9 +220,9 @@ static ElfW(Sym) gLibDlSymtab[] = {
// Note that adding any new symbols here requires stubbing them out in libdl.
static unsigned gLibDlBuckets[1] = { 1 };
#if defined(__arm__)
-static unsigned gLibDlChains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
+static unsigned gLibDlChains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0 };
#else
-static unsigned gLibDlChains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 0 };
+static unsigned gLibDlChains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
#endif
// This is used by the dynamic linker. Every process gets these symbols for free.
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 8e4c13c..2e145b5 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -811,11 +811,15 @@ void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
}
}
-soinfo* do_dlopen(const char* name, int flags) {
+soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo) {
if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL)) != 0) {
DL_ERR("invalid flags to dlopen: %x", flags);
return NULL;
}
+ if (extinfo != NULL && ((extinfo->flags & ~(ANDROID_DLEXT_VALID_FLAG_BITS)) != 0)) {
+ DL_ERR("invalid extended flags to android_dlopen_ext: %x", extinfo->flags);
+ return NULL;
+ }
set_soinfo_pool_protection(PROT_READ | PROT_WRITE);
soinfo* si = find_library(name);
if (si != NULL) {
diff --git a/linker/linker.h b/linker/linker.h
index b8d0587..93ab51d 100644
--- a/linker/linker.h
+++ b/linker/linker.h
@@ -32,6 +32,7 @@
#include <elf.h>
#include <link.h>
#include <unistd.h>
+#include <android/dlext.h>
#include "private/libc_logging.h"
@@ -192,7 +193,7 @@ extern soinfo libdl_info;
void do_android_get_LD_LIBRARY_PATH(char*, size_t);
void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
-soinfo* do_dlopen(const char* name, int flags);
+soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo);
int do_dlclose(soinfo* si);
ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start);