Revert "Add support for protected local symbol lookup."
This reverts commitd97e9f546e
. Bug: 17107521 (cherry picked from commit9419420919
) Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
This commit is contained in:
@@ -125,11 +125,6 @@ enum RelocationKind {
|
||||
kRelocMax
|
||||
};
|
||||
|
||||
enum class SymbolLookupScope {
|
||||
kAllowLocal,
|
||||
kExcludeLocal,
|
||||
};
|
||||
|
||||
#if STATS
|
||||
struct linker_stats_t {
|
||||
int count[kRelocMax];
|
||||
@@ -433,7 +428,7 @@ int dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void
|
||||
return rv;
|
||||
}
|
||||
|
||||
static ElfW(Sym)* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name, const SymbolLookupScope& lookup_scope) {
|
||||
static ElfW(Sym)* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name) {
|
||||
ElfW(Sym)* symtab = si->symtab;
|
||||
const char* strtab = si->strtab;
|
||||
|
||||
@@ -444,6 +439,7 @@ static ElfW(Sym)* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name,
|
||||
ElfW(Sym)* s = symtab + n;
|
||||
if (strcmp(strtab + s->st_name, name)) continue;
|
||||
|
||||
/* only concern ourselves with global and weak symbol definitions */
|
||||
switch (ELF_ST_BIND(s->st_info)) {
|
||||
case STB_GLOBAL:
|
||||
case STB_WEAK:
|
||||
@@ -456,13 +452,7 @@ static ElfW(Sym)* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name,
|
||||
static_cast<size_t>(s->st_size));
|
||||
return s;
|
||||
case STB_LOCAL:
|
||||
if (lookup_scope != SymbolLookupScope::kAllowLocal) {
|
||||
continue;
|
||||
}
|
||||
TRACE_TYPE(LOOKUP, "FOUND LOCAL %s in %s (%p) %zd",
|
||||
name, si->name, reinterpret_cast<void*>(s->st_value),
|
||||
static_cast<size_t>(s->st_size));
|
||||
return s;
|
||||
continue;
|
||||
default:
|
||||
__libc_fatal("ERROR: Unexpected ST_BIND value: %d for '%s' in '%s'",
|
||||
ELF_ST_BIND(s->st_info), name, si->name);
|
||||
@@ -523,7 +513,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
|
||||
*/
|
||||
|
||||
if (si == somain) {
|
||||
s = soinfo_elf_lookup(si, elf_hash, name, SymbolLookupScope::kAllowLocal);
|
||||
s = soinfo_elf_lookup(si, elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*lsi = si;
|
||||
goto done;
|
||||
@@ -540,7 +530,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
|
||||
if (!si->has_DT_SYMBOLIC) {
|
||||
DEBUG("%s: looking up %s in executable %s",
|
||||
si->name, name, somain->name);
|
||||
s = soinfo_elf_lookup(somain, elf_hash, name, SymbolLookupScope::kExcludeLocal);
|
||||
s = soinfo_elf_lookup(somain, elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*lsi = somain;
|
||||
goto done;
|
||||
@@ -557,7 +547,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
|
||||
* and some the first non-weak definition. This is system dependent.
|
||||
* Here we return the first definition found for simplicity. */
|
||||
|
||||
s = soinfo_elf_lookup(si, elf_hash, name, SymbolLookupScope::kAllowLocal);
|
||||
s = soinfo_elf_lookup(si, elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*lsi = si;
|
||||
goto done;
|
||||
@@ -571,7 +561,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
|
||||
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, SymbolLookupScope::kExcludeLocal);
|
||||
s = soinfo_elf_lookup(somain, elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*lsi = somain;
|
||||
goto done;
|
||||
@@ -582,7 +572,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
|
||||
|
||||
/* 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, SymbolLookupScope::kExcludeLocal);
|
||||
s = soinfo_elf_lookup(g_ld_preloads[i], elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*lsi = g_ld_preloads[i];
|
||||
goto done;
|
||||
@@ -592,7 +582,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
|
||||
for (int i = 0; needed[i] != NULL; i++) {
|
||||
DEBUG("%s: looking up %s in %s",
|
||||
si->name, name, needed[i]->name);
|
||||
s = soinfo_elf_lookup(needed[i], elf_hash, name, SymbolLookupScope::kExcludeLocal);
|
||||
s = soinfo_elf_lookup(needed[i], elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*lsi = needed[i];
|
||||
goto done;
|
||||
@@ -628,7 +618,7 @@ class SoinfoListAllocatorRW {
|
||||
|
||||
// This is used by dlsym(3). It performs symbol lookup only within the
|
||||
// specified soinfo object and its dependencies in breadth first order.
|
||||
ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name, soinfo* caller) {
|
||||
ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name) {
|
||||
LinkedList<soinfo, SoinfoListAllocatorRW> visit_list;
|
||||
LinkedList<soinfo, SoinfoListAllocatorRW> visited;
|
||||
visit_list.push_back(si);
|
||||
@@ -638,8 +628,7 @@ ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name, soi
|
||||
continue;
|
||||
}
|
||||
|
||||
ElfW(Sym)* result = soinfo_elf_lookup(current_soinfo, elfhash(name), name,
|
||||
caller == current_soinfo ? SymbolLookupScope::kAllowLocal : SymbolLookupScope::kExcludeLocal);
|
||||
ElfW(Sym)* result = soinfo_elf_lookup(current_soinfo, elfhash(name), name);
|
||||
|
||||
if (result != nullptr) {
|
||||
*found = current_soinfo;
|
||||
@@ -664,7 +653,7 @@ ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name, soi
|
||||
beginning of the global solist. Otherwise the search starts at the
|
||||
specified soinfo (for RTLD_NEXT).
|
||||
*/
|
||||
ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start, soinfo* caller) {
|
||||
ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start) {
|
||||
unsigned elf_hash = elfhash(name);
|
||||
|
||||
if (start == NULL) {
|
||||
@@ -673,8 +662,7 @@ ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start,
|
||||
|
||||
ElfW(Sym)* s = NULL;
|
||||
for (soinfo* si = start; (s == NULL) && (si != NULL); si = si->next) {
|
||||
s = soinfo_elf_lookup(si, elf_hash, name,
|
||||
caller == si ? SymbolLookupScope::kAllowLocal : SymbolLookupScope::kExcludeLocal);
|
||||
s = soinfo_elf_lookup(si, elf_hash, name);
|
||||
if (s != NULL) {
|
||||
*found = si;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user