about summary refs log tree commit diff stats
path: root/src/wrapped
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-02-16 13:44:54 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-02-16 13:44:54 +0100
commit65f75b0cc0ead29db622afc790b6167c476e4960 (patch)
treef4a2ab63e4f12ba67995a25c029468807d5e83fe /src/wrapped
parentc50b0ef9e8342b634af873134a52ec3b7b889f42 (diff)
downloadbox64-65f75b0cc0ead29db622afc790b6167c476e4960.tar.gz
box64-65f75b0cc0ead29db622afc790b6167c476e4960.zip
[ELFLOADER] Better handling of STB_GNU_UNIQUE binded symbol (prevent dlclose)
Diffstat (limited to 'src/wrapped')
-rw-r--r--src/wrapped/wrappedlibdl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c
index f85b007d..b781b9cb 100644
--- a/src/wrapped/wrappedlibdl.c
+++ b/src/wrapped/wrappedlibdl.c
@@ -386,6 +386,7 @@ void* my_dlsym(x64emu_t* emu, void *handle, void *symbol)
     pthread_mutex_unlock(&mutex);
     return (void*)start;
 }
+static int actualy_closing = 0;
 int my_dlclose(x64emu_t* emu, void *handle)
 {
     (void)emu;
@@ -410,7 +411,9 @@ int my_dlclose(x64emu_t* emu, void *handle)
         return -1;
     }
     --dl->dllibs[nlib].count;
-    DecRefCount(&dl->dllibs[nlib].lib, emu);
+    elfheader_t* h = GetElf(dl->dllibs[nlib].lib);
+    if(!h || !h->gnuunique || actualy_closing)
+        DecRefCount(&dl->dllibs[nlib].lib, emu);
     return 0;
 }
 #ifdef ANDROID
@@ -597,6 +600,7 @@ EXPORT int my__dl_find_object(x64emu_t* emu, void* addr, my_dl_find_object_t* re
 void closeAllDLOpenned()
 {
     dlprivate_t *dl = my_context->dlprivate;
+    actualy_closing = 1;
     if(dl) {
         x64emu_t* emu = thread_get_emu();
         for(size_t i=0; i<dl->lib_sz; ++i)