From ae1739f33070b2733b5472723e8f449234bb2c6d Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 3 Dec 2024 10:23:18 +0100 Subject: Improved dlsym wrapped function, will find more symbols from emulated libs --- src/wrapped/wrappedlibdl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c index bffa666f..d7831740 100644 --- a/src/wrapped/wrappedlibdl.c +++ b/src/wrapped/wrappedlibdl.c @@ -422,9 +422,16 @@ void* my_dlsym(x64emu_t* emu, void *handle, void *symbol) return NULL; } } else { - // still usefull? + // for "self" dlopen // => look globably - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL, 0, NULL)) { + //look in main elf first + int found = 0; + if(ElfGetSymTabStartEnd(my_context->elfs[0], &start, &end, rsymbol)) + found = 1; + if(!found && GetSymTabStartEnd(my_context->maplib, rsymbol, &start, &end)) + //if(!found && GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL, 0, NULL)) + found = 1; + if(found) { printf_dlsym(LOG_NEVER, "%p\n", (void*)start); pthread_mutex_unlock(&mutex); return (void*)start; -- cgit 1.4.1