diff options
| author | Elliott Hughes <enh@google.com> | 2014-01-13 16:37:47 -0800 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2014-01-13 16:37:47 -0800 |
| commit | a4aafd156068ee174012f28cd894dbecf0e4ab90 (patch) | |
| tree | d55b5e77d1fa752db1f374d0baec3afc9c15ecd5 /linker/linker.cpp | |
| parent | ebc1c76d77dd604f16126e66b2171e8ee6fa1d22 (diff) | |
| download | bionic-a4aafd156068ee174012f28cd894dbecf0e4ab90.zip bionic-a4aafd156068ee174012f28cd894dbecf0e4ab90.tar.gz bionic-a4aafd156068ee174012f28cd894dbecf0e4ab90.tar.bz2 | |
Make it possible for code to query the dynamic linker's default search path.
We're not going to have init(1) set LD_LIBRARY_PATH globally on 64-bit.
This patch makes it possible for libnativehelper to set LD_LIBRARY_PATH
in each Java VM (to support System.loadLibrary) without also hard-coding
the default search path there.
Change-Id: If13961fae976e06dd80d5ef522f31e8b7eb01154
Diffstat (limited to 'linker/linker.cpp')
| -rwxr-xr-x | linker/linker.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index f4e426d..f58e222 100755 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -50,13 +50,6 @@ #include "linker_environ.h" #include "linker_phdr.h" -/* Assume average path length of 64 and max 8 paths */ -#define LDPATH_BUFSIZE 512 -#define LDPATH_MAX 8 - -#define LDPRELOAD_BUFSIZE 512 -#define LDPRELOAD_MAX 8 - /* >>> IMPORTANT NOTE - READ ME BEFORE MODIFYING <<< * * Do NOT use malloc() and friends or pthread_*() code here. @@ -91,7 +84,7 @@ static soinfo* solist = &libdl_info; static soinfo* sonext = &libdl_info; static soinfo* somain; /* main process, always the one after libdl_info */ -static const char* const gSoPaths[] = { +static const char* const gDefaultLdPaths[] = { #if defined(__LP64__) "/vendor/lib64", "/system/lib64", @@ -102,6 +95,12 @@ static const char* const gSoPaths[] = { NULL }; +#define LDPATH_BUFSIZE (LDPATH_MAX*64) +#define LDPATH_MAX 8 + +#define LDPRELOAD_BUFSIZE (LDPRELOAD_MAX*64) +#define LDPRELOAD_MAX 8 + static char gLdPathsBuffer[LDPATH_BUFSIZE]; static const char* gLdPaths[LDPATH_MAX + 1]; @@ -708,7 +707,7 @@ static int open_library(const char* name) { // Otherwise we try LD_LIBRARY_PATH first, and fall back to the built-in well known paths. int fd = open_library_on_path(name, gLdPaths); if (fd == -1) { - fd = open_library_on_path(name, gSoPaths); + fd = open_library_on_path(name, gDefaultLdPaths); } return fd; } @@ -828,6 +827,10 @@ static int soinfo_unload(soinfo* si) { return 0; } +void do_android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size) { + snprintf(buffer, buffer_size, "%s:%s", gDefaultLdPaths[0], gDefaultLdPaths[1]); +} + void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) { if (!get_AT_SECURE()) { parse_LD_LIBRARY_PATH(ld_library_path); |
