about summary refs log tree commit diff stats
path: root/src/librarian
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-07-09 11:58:35 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-07-09 11:58:35 +0200
commitec3786f86295b0fb769970bcb3c77b4ffffd7d48 (patch)
treeeeda9ecd7394e93eac2f759786ac3f7c19a1334b /src/librarian
parent0e761801deb4aa045e6052dee454973587e8dd4b (diff)
downloadbox64-ec3786f86295b0fb769970bcb3c77b4ffffd7d48.tar.gz
box64-ec3786f86295b0fb769970bcb3c77b4ffffd7d48.zip
Various improvement and some workaround to support musl binary (for #324)
Diffstat (limited to 'src/librarian')
-rwxr-xr-xsrc/librarian/library.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/librarian/library.c b/src/librarian/library.c
index 2c8ebd5a..57cef4e4 100755
--- a/src/librarian/library.c
+++ b/src/librarian/library.c
@@ -279,6 +279,13 @@ static int loadEmulatedLib(const char* libname, library_t *lib, box64context_t*
         lib->priv.n.weaksymbols = kh_init(mapsymbols);
         lib->priv.n.localsymbols = kh_init(mapsymbols);
 
+        if(strcmp(lib->path, libname)) {
+            free(lib->path);
+            lib->path = realpath(libname, NULL);
+            if(!lib->path)
+                lib->path = strdup(libname);
+        }
+
         printf_log(LOG_INFO, "Using emulated %s\n", libname);
         #ifdef DYNAREC
         if(libname && strstr(libname, "libmonobdwgc-2.0.so")) {
@@ -334,7 +341,9 @@ library_t *NewLibrary(const char* path, box64context_t* context)
 {
     printf_log(LOG_DEBUG, "Trying to load \"%s\"\n", path);
     library_t *lib = (library_t*)calloc(1, sizeof(library_t));
-    lib->path = strdup(path);
+    lib->path = realpath(path, NULL);
+    if(!lib->path)
+        lib->path = strdup(path);
     if(libGL && !strcmp(path, libGL))
         lib->name = strdup("libGL.so.1");
     else
@@ -557,7 +566,9 @@ int IsSameLib(library_t* lib, const char* path)
         if(strcmp(name, lib->name)==0)
             ret=1;
     } else {
-        if(!strcmp(path, lib->path))
+        char rpath[PATH_MAX];
+        realpath(path, rpath);
+        if(!strcmp(rpath, lib->path))
             ret=1;
     }
     if(!ret) {