about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-05-31 18:04:25 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-05-31 18:04:25 +0200
commit104cf8a58b5c15b19d961f66375ff70c8d14a8cf (patch)
treeeacf2f81dc7848abc173feec30a2f214ce588bd8 /src
parent976f175aa9f17adc4dc1530053861fbb8383fee7 (diff)
downloadbox64-104cf8a58b5c15b19d961f66375ff70c8d14a8cf.tar.gz
box64-104cf8a58b5c15b19d961f66375ff70c8d14a8cf.zip
Some adjustements to elfloader needed libs loading
Diffstat (limited to 'src')
-rwxr-xr-xsrc/box64context.c6
-rwxr-xr-xsrc/librarian/librarian.c16
-rwxr-xr-xsrc/wrapped/wrappedlibc_private.h2
3 files changed, 17 insertions, 7 deletions
diff --git a/src/box64context.c b/src/box64context.c
index 2688b124..4b4ae956 100755
--- a/src/box64context.c
+++ b/src/box64context.c
@@ -313,6 +313,9 @@ void add_neededlib(needed_libs_t* needed, library_t* lib)
 {
     if(!needed)
         return;
+    for(int i=0; i<needed->size; ++i)
+        if(needed->libs[i] == lib)
+            return;
     if(needed->size == needed->cap) {
         needed->cap += 8;
         needed->libs = (library_t**)realloc(needed->libs, needed->cap*sizeof(library_t*));
@@ -335,6 +338,9 @@ void add_dependedlib(needed_libs_t* depended, library_t* lib)
 {
     if(!depended)
         return;
+    for(int i=0; i<depended->size; ++i)
+        if(depended->libs[i] == lib)
+            return;
     if(depended->size == depended->cap) {
         depended->cap += 8;
         depended->libs = (library_t**)realloc(depended->libs, depended->cap*sizeof(library_t*));
diff --git a/src/librarian/librarian.c b/src/librarian/librarian.c
index 2cec106b..3273eeda 100755
--- a/src/librarian/librarian.c
+++ b/src/librarian/librarian.c
@@ -170,14 +170,13 @@ void MapLibAddMapLib(lib_t* dest, lib_t* src)
         return;
     for(int i=0; i<src->libsz; ++i) {
         library_t* lib = src->libraries[i];
-        if(!lib) continue;
+        if(!lib || libraryInMapLib(dest, lib)) continue;
+        MapLibAddLib(dest, lib);
         if(lib->maplib && src!=lib->maplib) {   //TODO: find why is src!=lib->maplib needed
             MapLibAddMapLib(dest, lib->maplib);
             free(lib->maplib);
             lib->maplib = NULL;
         }
-        if(!libraryInMapLib(dest, lib))
-            MapLibAddLib(dest, lib);
     }
 }
 
@@ -314,13 +313,18 @@ int AddNeededLib(lib_t* maplib, needed_libs_t* neededlibs, library_t* deplib, in
     int idx = neededlibs->size;
     // Add libs and symbol
     for(int i=0; i<npath; ++i) {
-        if(AddNeededLib_add(maplib, neededlibs, deplib, local, paths[i], box64, emu))
+        if(AddNeededLib_add(maplib, neededlibs, deplib, local, paths[i], box64, emu)) {
+            printf_log(LOG_INFO, "Error loading needed lib %s\n", paths[i]);
             return 1;
+        }
     }
+    int idx_end = neededlibs->size;
     // add dependant libs and init them
-    for (int i=idx; i<neededlibs->size; ++i)
-        if(AddNeededLib_init(maplib, neededlibs, deplib, local, neededlibs->libs[i], box64, emu))
+    for (int i=idx; i<idx_end; ++i)
+        if(AddNeededLib_init(maplib, neededlibs, deplib, local, neededlibs->libs[i], box64, emu)) {
+            printf_log(LOG_INFO, "Error initializing needed lib %s\n", neededlibs->libs[i]->name);
             if(!allow_missing_libs) return 1;
+        }
     return 0;
 }
 
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index 16991f8d..89f70935 100755
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -1453,7 +1453,7 @@ GOM(qsort_r, vFEpLLpp)  //Weak
 //GO(quick_exit, 
 //GO(quick_exit, 
 //GO(quotactl, 
-//GO(raise, 
+GO(raise, iFi)
 GO(rand, iFv)
 GOW(random, lFv)
 //GOW(random_r,