summaryrefslogtreecommitdiffstats
path: root/linker/dlfcn.cpp
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2015-03-31 11:14:03 -0700
committerDimitry Ivanov <dimitry@google.com>2015-04-06 21:15:43 +0000
commitaae859cc3ca127d890e853cbf12b731e05624a22 (patch)
tree159e996dd6756b99fe70371e99a69ec6040e851b /linker/dlfcn.cpp
parente686df8d839216460f02cf7db6c4e26a13e49afd (diff)
downloadbionic-aae859cc3ca127d890e853cbf12b731e05624a22.zip
bionic-aae859cc3ca127d890e853cbf12b731e05624a22.tar.gz
bionic-aae859cc3ca127d890e853cbf12b731e05624a22.tar.bz2
Add realpath for soinfo
This change adds realpath to soinfo and extends limit on filenames from 128 to PATH_MAX. It also removes soinfo::name field, linker uses dt_soname instead. Bug: http://b/19818481 Bug: https://code.google.com/p/android/issues/detail?id=80336 Change-Id: I9cff4cb5bda3ee2bc74e1bbded9594ea7fbe2a08
Diffstat (limited to 'linker/dlfcn.cpp')
-rw-r--r--linker/dlfcn.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 479e831..5ed8891 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -136,7 +136,7 @@ int dladdr(const void* addr, Dl_info* info) {
memset(info, 0, sizeof(Dl_info));
- info->dli_fname = si->name;
+ info->dli_fname = si->get_realpath();
// Address at which the shared object is loaded.
info->dli_fbase = reinterpret_cast<void*>(si->base);
@@ -228,23 +228,28 @@ static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0 };
static unsigned g_libdl_chains[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
#endif
-static soinfo __libdl_info("libdl.so", nullptr, 0, RTLD_GLOBAL);
+static uint8_t __libdl_info_buf[sizeof(soinfo)] __attribute__((aligned(8)));
+static soinfo* __libdl_info = nullptr;
// This is used by the dynamic linker. Every process gets these symbols for free.
soinfo* get_libdl_info() {
- if ((__libdl_info.flags_ & FLAG_LINKED) == 0) {
- __libdl_info.flags_ |= FLAG_LINKED;
- __libdl_info.strtab_ = ANDROID_LIBDL_STRTAB;
- __libdl_info.symtab_ = g_libdl_symtab;
- __libdl_info.nbucket_ = sizeof(g_libdl_buckets)/sizeof(unsigned);
- __libdl_info.nchain_ = sizeof(g_libdl_chains)/sizeof(unsigned);
- __libdl_info.bucket_ = g_libdl_buckets;
- __libdl_info.chain_ = g_libdl_chains;
- __libdl_info.ref_count_ = 1;
- __libdl_info.strtab_size_ = sizeof(ANDROID_LIBDL_STRTAB);
- __libdl_info.local_group_root_ = &__libdl_info;
- __libdl_info.soname_ = "libdl.so";
+ if (__libdl_info == nullptr) {
+ __libdl_info = new (__libdl_info_buf) soinfo("libdl.so", nullptr, 0, RTLD_GLOBAL);
+ __libdl_info->flags_ |= FLAG_LINKED;
+ __libdl_info->strtab_ = ANDROID_LIBDL_STRTAB;
+ __libdl_info->symtab_ = g_libdl_symtab;
+ __libdl_info->nbucket_ = sizeof(g_libdl_buckets)/sizeof(unsigned);
+ __libdl_info->nchain_ = sizeof(g_libdl_chains)/sizeof(unsigned);
+ __libdl_info->bucket_ = g_libdl_buckets;
+ __libdl_info->chain_ = g_libdl_chains;
+ __libdl_info->ref_count_ = 1;
+ __libdl_info->strtab_size_ = sizeof(ANDROID_LIBDL_STRTAB);
+ __libdl_info->local_group_root_ = __libdl_info;
+ __libdl_info->soname_ = "libdl.so";
+#if defined(__arm__)
+ strlcpy(__libdl_info->old_name_, __libdl_info->soname_, sizeof(__libdl_info->old_name_));
+#endif
}
- return &__libdl_info;
+ return __libdl_info;
}