about summary refs log tree commit diff stats
path: root/src/main.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-25 14:03:28 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-04-25 14:03:28 +0200
commit549c42ac1913c06547abcc99c8ebb6dc745fe4e4 (patch)
treebb469a406f9e457ad231acf5a747f715e8985726 /src/main.c
parent6bfeb156551ce98d4feafb6fe764bbe4fd1cab03 (diff)
downloadbox64-549c42ac1913c06547abcc99c8ebb6dc745fe4e4.tar.gz
box64-549c42ac1913c06547abcc99c8ebb6dc745fe4e4.zip
Improved/fixed (agaaaaain) Load/Unload of library (might help #740 &nd #742)
Diffstat (limited to 'src/main.c')
-rwxr-xr-xsrc/main.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index b942f978..a8b0cff3 100755
--- a/src/main.c
+++ b/src/main.c
@@ -1701,12 +1701,19 @@ int main(int argc, const char **argv, char **env) {
     AddMainElfToLinkmap(elf_header);
     // pre-load lib if needed
     if(ld_preload.size) {
-        my_context->preload = new_neededlib(ld_preload.size);
-        for(int i=0; i<ld_preload.size; ++i)
-            my_context->preload->names[i] = ld_preload.paths[i];
-        if(AddNeededLib(my_context->maplib, 0, 0, my_context->preload, my_context, emu)) {
-            printf_log(LOG_INFO, "Warning, cannot pre-load of the libs\n");
-        }            
+        my_context->preload = new_neededlib(0);
+        for(int i=0; i<ld_preload.size; ++i) {
+            needed_libs_t* tmp = new_neededlib(1);
+            tmp->names[0] = ld_preload.paths[i];
+            if(AddNeededLib(my_context->maplib, 0, 0, tmp, my_context, emu)) {
+                printf_log(LOG_INFO, "Warning, cannot pre-load of %s\n", tmp->names[0]);
+                RemoveNeededLib(my_context->maplib, 0, tmp, my_context, emu);
+            } else {
+                for(int j=0; j<tmp->size; ++j)
+                    add1lib_neededlib(my_context->preload, tmp->libs[j], tmp->names[j]);
+                free_neededlib(tmp);
+            }
+        }
     }
     FreeCollection(&ld_preload);
     // Call librarian to load all dependant elf