Count references for groups instead of instances

Count references on the group level to avoid
  partially unloading function that might be
  referenced by other libraries in the local_group

  Bonus: with this change we can correctly unload recursively
  linked libraries. is_recursive check is removed.

  Also dynamic executables (not .so) with 0 DT_NEEDED libraries
  are now correctly linked.

Change-Id: Idfa83baef402840599b93a875f2881d9f020dbcd
This commit is contained in:
Dmitriy Ivanov
2014-11-29 13:57:41 -08:00
parent f64c43ba6c
commit ab972b9adf
13 changed files with 407 additions and 116 deletions

View File

@@ -236,16 +236,17 @@ static soinfo __libdl_info("libdl.so", nullptr, 0, RTLD_GLOBAL);
// 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;
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.ref_count_ = 1;
__libdl_info.strtab_size_ = sizeof(ANDROID_LIBDL_STRTAB);
__libdl_info.local_group_root_ = &__libdl_info;
}
return &__libdl_info;