about summary refs log tree commit diff stats
path: root/src/librarian
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-28 17:13:37 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-04-28 17:14:00 +0200
commit14e20e643515d4e7171f54e6d2fb78cf784f7d10 (patch)
treef4ebb79470ce3f172087346546b99d7c5e884108 /src/librarian
parent93abd016b451d63355dbc02fdbed431f6eacc810 (diff)
downloadbox64-14e20e643515d4e7171f54e6d2fb78cf784f7d10.tar.gz
box64-14e20e643515d4e7171f54e6d2fb78cf784f7d10.zip
Fix for local library open using dlopen that are then promoted to global with another dlopen (help java 17, probably other too)
Diffstat (limited to 'src/librarian')
-rwxr-xr-xsrc/librarian/librarian.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/librarian/librarian.c b/src/librarian/librarian.c
index e480f907..d9f20a9a 100755
--- a/src/librarian/librarian.c
+++ b/src/librarian/librarian.c
@@ -156,6 +156,27 @@ static void MapLibRemoveMapLib(lib_t* dest, lib_t* src)
     }
 }
 
+void promoteLocalLibGlobal(library_t* lib)
+{
+    if(!lib || !my_context)
+        return;
+    // promote lib from local to global...
+    // for add the depending local libs...
+    if(lib->maplib) {
+        MapLibAddMapLib(my_context->maplib, lib, lib->maplib);
+    }
+    if(!libraryInMapLib(my_context->maplib, lib))
+        MapLibAddLib(my_context->maplib, lib);
+    MapLibRemoveMapLib(my_context->local_maplib, my_context->maplib);
+}
+
+int isLibLocal(library_t* lib)
+{
+    if(!lib || !my_context)
+        return 0;
+    return libraryInMapLib(my_context->local_maplib, lib);
+}
+
 int AddNeededLib_add(lib_t* maplib, int local, needed_libs_t* needed, int n, box64context_t* box64, x64emu_t* emu)
 {
     const char* path = needed->names[n];
@@ -187,13 +208,7 @@ int AddNeededLib_add(lib_t* maplib, int local, needed_libs_t* needed, int n, box
             }
         } else {
             // promote lib from local to global...
-            // for add the depending local libs...
-            if(lib->maplib) {
-                MapLibAddMapLib(my_context->maplib, lib, lib->maplib);
-            }
-            if(!libraryInMapLib(my_context->maplib, lib))
-                MapLibAddLib(my_context->maplib, lib);
-            MapLibRemoveMapLib(my_context->local_maplib, my_context->maplib);
+            promoteLocalLibGlobal(lib);
         }
         return 0;
     }