From 0dc63f8fa9be289a196c03e4ee668ff9f891c483 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 19 Apr 2018 18:28:29 +0300 Subject: linker: Use dladdr1 to get symbol info Casting symbol is wrong. --- src/linker/linker.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/linker') diff --git a/src/linker/linker.c b/src/linker/linker.c index 25b1b3d..b5b782d 100644 --- a/src/linker/linker.c +++ b/src/linker/linker.c @@ -1384,9 +1384,10 @@ static int apkenv_reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count) } if(sym_addr != 0) { - if(ELF32_ST_TYPE(((Elf32_Sym*)(intptr_t)sym_addr)->st_info) == STT_FUNC) { + Dl_info info; + ElfW(Sym) *extra; + if (dladdr1((void*)sym_addr, &info, (void**) &extra, RTLD_DL_SYMENT) && extra && ELF32_ST_TYPE(extra->st_info) == STT_FUNC) sym_addr = (unsigned)wrapper_create(sym_name, (void*)sym_addr); - } } else if(s == NULL) { /* We only allow an undefined symbol if this is a weak -- cgit v1.2.3-70-g09d2