Fix weak function lookups

* Linker now correctly resolves function defined
   with __attribute__((weak)).

Bug: https://code.google.com/p/android/issues/detail?id=70206
Change-Id: I82efb905676c25fefb1b11a13f5fecb0f1384657
This commit is contained in:
Dmitriy Ivanov
2014-06-17 15:56:38 -07:00
parent 1d2b4c022c
commit ce44166c73
4 changed files with 45 additions and 1 deletions

View File

@@ -118,7 +118,7 @@ void* dlsym(void* handle, const char* symbol) {
if (sym != NULL) {
unsigned bind = ELF_ST_BIND(sym->st_info);
if (bind == STB_GLOBAL && sym->st_shndx != 0) {
if ((bind == STB_GLOBAL || bind == STB_WEAK) && sym->st_shndx != 0) {
return reinterpret_cast<void*>(sym->st_value + found->load_bias);
}