am aea393c0: Merge "Remove has_DT_SYMBOLIC flag"
				
					
				
			* commit 'aea393c096460669647acbe803617affc5bc0697': Remove has_DT_SYMBOLIC flag
This commit is contained in:
		@@ -244,7 +244,6 @@ soinfo* get_libdl_info() {
 | 
			
		||||
    __libdl_info.nchain = sizeof(g_libdl_chains)/sizeof(unsigned);
 | 
			
		||||
    __libdl_info.bucket = g_libdl_buckets;
 | 
			
		||||
    __libdl_info.chain = g_libdl_chains;
 | 
			
		||||
    __libdl_info.has_DT_SYMBOLIC = true;
 | 
			
		||||
    __libdl_info.ref_count = 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -486,50 +486,22 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi) {
 | 
			
		||||
  ElfW(Sym)* s = nullptr;
 | 
			
		||||
 | 
			
		||||
  if (somain != nullptr) {
 | 
			
		||||
    /*
 | 
			
		||||
     * Local scope is executable scope. Just start looking into it right away
 | 
			
		||||
     * for the shortcut.
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    if (si == somain) {
 | 
			
		||||
      s = soinfo_elf_lookup(si, elf_hash, name);
 | 
			
		||||
      if (s != nullptr) {
 | 
			
		||||
        *lsi = si;
 | 
			
		||||
        goto done;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      /* Next, look for it in the preloads list */
 | 
			
		||||
      for (int i = 0; g_ld_preloads[i] != NULL; i++) {
 | 
			
		||||
        s = soinfo_elf_lookup(g_ld_preloads[i], elf_hash, name);
 | 
			
		||||
        if (s != NULL) {
 | 
			
		||||
          *lsi = g_ld_preloads[i];
 | 
			
		||||
          goto done;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      /* Order of symbol lookup is controlled by DT_SYMBOLIC flag */
 | 
			
		||||
 | 
			
		||||
      /*
 | 
			
		||||
       * If this object was built with symbolic relocations disabled, the
 | 
			
		||||
       * first place to look to resolve external references is the main
 | 
			
		||||
       * executable.
 | 
			
		||||
       */
 | 
			
		||||
 | 
			
		||||
      if (!si->has_DT_SYMBOLIC) {
 | 
			
		||||
    DEBUG("%s: looking up %s in executable %s",
 | 
			
		||||
          si->name, name, somain->name);
 | 
			
		||||
 | 
			
		||||
    // 1. Look for it in the main executable
 | 
			
		||||
    s = soinfo_elf_lookup(somain, elf_hash, name);
 | 
			
		||||
    if (s != nullptr) {
 | 
			
		||||
      *lsi = somain;
 | 
			
		||||
          goto done;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        /* Next, look for it in the preloads list */
 | 
			
		||||
    // 2. Look for it in the ld_preloads
 | 
			
		||||
    if (s == nullptr) {
 | 
			
		||||
      for (int i = 0; g_ld_preloads[i] != NULL; i++) {
 | 
			
		||||
        s = soinfo_elf_lookup(g_ld_preloads[i], elf_hash, name);
 | 
			
		||||
          if (s != NULL) {
 | 
			
		||||
        if (s != nullptr) {
 | 
			
		||||
          *lsi = g_ld_preloads[i];
 | 
			
		||||
            goto done;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@@ -544,38 +516,15 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi) {
 | 
			
		||||
     * and some the first non-weak definition.   This is system dependent.
 | 
			
		||||
     * Here we return the first definition found for simplicity.  */
 | 
			
		||||
 | 
			
		||||
    if (s == nullptr) {
 | 
			
		||||
      s = soinfo_elf_lookup(si, elf_hash, name);
 | 
			
		||||
      if (s != nullptr) {
 | 
			
		||||
        *lsi = si;
 | 
			
		||||
        goto done;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      /*
 | 
			
		||||
       * If this object was built with -Bsymbolic and symbol is not found
 | 
			
		||||
       * in the local scope, try to find the symbol in the main executable.
 | 
			
		||||
       */
 | 
			
		||||
 | 
			
		||||
      if (si->has_DT_SYMBOLIC) {
 | 
			
		||||
        DEBUG("%s: looking up %s in executable %s after local scope",
 | 
			
		||||
              si->name, name, somain->name);
 | 
			
		||||
        s = soinfo_elf_lookup(somain, elf_hash, name);
 | 
			
		||||
        if (s != nullptr) {
 | 
			
		||||
          *lsi = somain;
 | 
			
		||||
          goto done;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /* Next, look for it in the preloads list */
 | 
			
		||||
        for (int i = 0; g_ld_preloads[i] != NULL; i++) {
 | 
			
		||||
          s = soinfo_elf_lookup(g_ld_preloads[i], elf_hash, name);
 | 
			
		||||
          if (s != NULL) {
 | 
			
		||||
            *lsi = g_ld_preloads[i];
 | 
			
		||||
            goto done;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (s == nullptr) {
 | 
			
		||||
    si->get_children().visit([&](soinfo* child) {
 | 
			
		||||
      DEBUG("%s: looking up %s in %s", si->name, name, child->name);
 | 
			
		||||
      s = soinfo_elf_lookup(child, elf_hash, name);
 | 
			
		||||
@@ -585,18 +534,17 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi) {
 | 
			
		||||
      }
 | 
			
		||||
      return true;
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
done:
 | 
			
		||||
  if (s != nullptr) {
 | 
			
		||||
    TRACE_TYPE(LOOKUP, "si %s sym %s s->st_value = %p, "
 | 
			
		||||
               "found in %s, base = %p, load bias = %p",
 | 
			
		||||
               si->name, name, reinterpret_cast<void*>(s->st_value),
 | 
			
		||||
               (*lsi)->name, reinterpret_cast<void*>((*lsi)->base),
 | 
			
		||||
               reinterpret_cast<void*>((*lsi)->load_bias));
 | 
			
		||||
    return s;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return nullptr;
 | 
			
		||||
  return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Each size has it's own allocator.
 | 
			
		||||
@@ -2026,7 +1974,7 @@ bool soinfo::PrelinkImage() {
 | 
			
		||||
        break;
 | 
			
		||||
#endif
 | 
			
		||||
      case DT_SYMBOLIC:
 | 
			
		||||
        has_DT_SYMBOLIC = true;
 | 
			
		||||
        // ignored
 | 
			
		||||
        break;
 | 
			
		||||
      case DT_NEEDED:
 | 
			
		||||
        ++needed_count;
 | 
			
		||||
@@ -2040,9 +1988,6 @@ bool soinfo::PrelinkImage() {
 | 
			
		||||
          has_text_relocations = true;
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
        if (d->d_un.d_val & DF_SYMBOLIC) {
 | 
			
		||||
          has_DT_SYMBOLIC = true;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
#if defined(__mips__)
 | 
			
		||||
      case DT_STRSZ:
 | 
			
		||||
@@ -2076,8 +2021,10 @@ bool soinfo::PrelinkImage() {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
      default:
 | 
			
		||||
        DEBUG("Unused DT entry: type %p arg %p",
 | 
			
		||||
        if (!relocating_linker) {
 | 
			
		||||
          DL_WARN("%s: unused DT entry: type %p arg %p", name,
 | 
			
		||||
              reinterpret_cast<void*>(d->d_tag), reinterpret_cast<void*>(d->d_un.d_val));
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -197,9 +197,7 @@ struct soinfo {
 | 
			
		||||
#if !defined(__LP64__)
 | 
			
		||||
  bool has_text_relocations;
 | 
			
		||||
#endif
 | 
			
		||||
  // TODO: remove this flag, dynamic linker
 | 
			
		||||
  // should not use it in any way.
 | 
			
		||||
  bool has_DT_SYMBOLIC;
 | 
			
		||||
  bool unused4; // DO NOT USE, maintained for compatibility
 | 
			
		||||
 | 
			
		||||
  soinfo(const char* name, const struct stat* file_stat, int rtld_flags);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user