diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-05-09 21:59:32 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-05-09 21:59:32 +0200 |
| commit | d38f659f428544de524fe6f2a49355a104055555 (patch) | |
| tree | c26f2d251706919f7496b8fe6d857acd75a6b888 /src | |
| parent | 6d95a644123181addb647f51712ad3e5782d5052 (diff) | |
| download | box64-d38f659f428544de524fe6f2a49355a104055555.tar.gz box64-d38f659f428544de524fe6f2a49355a104055555.zip | |
Changed the workaround for MiniMetro/Steam, using rcfile now (for #1311)
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 45 | ||||
| -rw-r--r-- | src/elfs/elfloader.c | 9 | ||||
| -rw-r--r-- | src/include/box64context.h | 1 | ||||
| -rw-r--r-- | src/librarian/library.c | 19 | ||||
| -rw-r--r-- | src/tools/rcfile.c | 8 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibgl.c | 6 |
6 files changed, 62 insertions, 26 deletions
diff --git a/src/core.c b/src/core.c index bc58b040..36ce41dd 100644 --- a/src/core.c +++ b/src/core.c @@ -55,6 +55,7 @@ int box64_cefdisablegpu = 0; int box64_cefdisablegpucompositor = 0; int box64_malloc_hack = 0; int box64_dynarec_test = 0; +path_collection_t box64_addlibs = {0}; int box64_maxcpu = 0; int box64_maxcpu_immutable = 0; #if defined(SD845) || defined(SD888) || defined(SD8G2) || defined(TEGRAX1) @@ -1195,6 +1196,12 @@ int GatherEnv(char*** dest, char** env, char* prog) return 0; } +void AddNewLibs(const char* list) +{ + AppendList(&box64_addlibs, list, 0); + printf_log(LOG_INFO, "BOX64: Adding %s to the libs\n", list); +} + void PrintFlags() { printf("Environment Variables:\n"); printf(" BOX64_PATH is the box64 version of PATH (default is '.:bin')\n"); @@ -1369,6 +1376,9 @@ void LoadEnvVars(box64context_t *context) printf_log(LOG_INFO, "BOX64: Disabling handling of SigILL\n"); } } + if(getenv("BOX64_ADDLIBS")) { + AddNewLibs(getenv("BOX64_ADDLIBS")); + } // check BOX64_PATH and load it LoadEnvPath(&context->box64_path, ".:bin", "BOX64_PATH"); if(getenv("PATH")) @@ -1834,24 +1844,23 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf printf_log(LOG_INFO, "%s ", ld_preload.paths[i]); printf_log(LOG_INFO, "\n"); } - } else { - if(getenv("LD_PRELOAD")) { - char* p = getenv("LD_PRELOAD"); - if(strstr(p, "libtcmalloc_minimal.so.0")) - box64_tcmalloc_minimal = 1; - if(strstr(p, "libtcmalloc_minimal.so.4")) - box64_tcmalloc_minimal = 1; - if(strstr(p, "libtcmalloc_minimal_debug.so.4")) - box64_tcmalloc_minimal = 1; - if(strstr(p, "libasan.so")) - box64_tcmalloc_minimal = 1; // it seems Address Sanitizer doesn't handle dlsym'd malloc very well - ParseList(p, &ld_preload, 0); - if (ld_preload.size && box64_log) { - printf_log(LOG_INFO, "BOX64 trying to Preload "); - for (int i=0; i<ld_preload.size; ++i) - printf_log(LOG_INFO, "%s ", ld_preload.paths[i]); - printf_log(LOG_INFO, "\n"); - } + } + if(getenv("LD_PRELOAD")) { + char* p = getenv("LD_PRELOAD"); + if(strstr(p, "libtcmalloc_minimal.so.0")) + box64_tcmalloc_minimal = 1; + if(strstr(p, "libtcmalloc_minimal.so.4")) + box64_tcmalloc_minimal = 1; + if(strstr(p, "libtcmalloc_minimal_debug.so.4")) + box64_tcmalloc_minimal = 1; + if(strstr(p, "libasan.so")) + box64_tcmalloc_minimal = 1; // it seems Address Sanitizer doesn't handle dlsym'd malloc very well + AppendList(&ld_preload, p, 0); + if (ld_preload.size && box64_log) { + printf_log(LOG_INFO, "BOX64 trying to Preload "); + for (int i=0; i<ld_preload.size; ++i) + printf_log(LOG_INFO, "%s ", ld_preload.paths[i]); + printf_log(LOG_INFO, "\n"); } } // print PATH and LD_LIB used diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index 1afda4be..efb0ef57 100644 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -928,7 +928,7 @@ void AddSymbols(lib_t *maplib, elfheader_t* h) checkHookedSymbols(h); #endif } - +extern path_collection_t box64_addlibs; /* $ORIGIN – Provides the directory the object was loaded from. This token is typical used for locating dependencies in unbundled packages. For more details of this @@ -1021,7 +1021,12 @@ int LoadNeededLibs(elfheader_t* h, lib_t *maplib, int local, int bindnow, int de for (size_t i=0; i<h->numDynamic; ++i) if(h->Dynamic[i].d_tag==DT_NEEDED) h->needed->names[j++] = h->DynStrTab+h->delta+h->Dynamic[i].d_un.d_val; - + if(h==my_context->elfs[0] && box64_addlibs.size) { + for(int i=0; i<box64_addlibs.size; ++i) { + printf_log(LOG_INFO, "BOX64, Adding %s to needed libs of %s\n", box64_addlibs.paths[i], h->name); + add1lib_neededlib_name(h->needed, NULL, box64_addlibs.paths[i]); + } + } // TODO: Add LD_LIBRARY_PATH and RPATH handling if(AddNeededLib(maplib, local, bindnow, deepbind, h->needed, h, box64, emu)) { printf_log(LOG_INFO, "Error loading one of needed lib\n"); diff --git a/src/include/box64context.h b/src/include/box64context.h index c3493e7e..19c45f90 100644 --- a/src/include/box64context.h +++ b/src/include/box64context.h @@ -69,6 +69,7 @@ needed_libs_t* new_neededlib(int n); needed_libs_t* copy_neededlib(needed_libs_t* needed); void add1_neededlib(needed_libs_t* needed); void add1lib_neededlib(needed_libs_t* needed, library_t* lib, const char* name); +void add1lib_neededlib_name(needed_libs_t* needed, library_t* lib, const char* name); void add1libref_neededlib(needed_libs_t* needed, library_t* lib); typedef struct base_segment_s { diff --git a/src/librarian/library.c b/src/librarian/library.c index 127339af..14a1334a 100644 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -1180,6 +1180,25 @@ void add1lib_neededlib(needed_libs_t* needed, library_t* lib, const char* name) needed->size++; needed->init_size++; } +void add1lib_neededlib_name(needed_libs_t* needed, library_t* lib, const char* name) +{ + if(!needed || !name) + return; + // check if lib is already present + for (int i=0; i<needed->size; ++i) + if(!strcmp(needed->names[i], name)) + return; + // add it + if(needed->size==needed->cap) { + needed->cap = needed->size+1; + needed->libs = (library_t**)realloc(needed->libs, needed->cap*sizeof(library_t*)); + needed->names = (char**)realloc(needed->names, needed->cap*sizeof(char*)); + } + needed->libs[needed->size] = lib; + needed->names[needed->size] = (char*)name; + needed->size++; + needed->init_size++; +} void add1libref_neededlib(needed_libs_t* needed, library_t* lib) { if(!needed || !lib) diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c index 34bf5cd4..3fc9c869 100644 --- a/src/tools/rcfile.c +++ b/src/tools/rcfile.c @@ -46,6 +46,9 @@ static const char default_rcfile[] = "[LotCG.x86_64]\n" "BOX64_DYNAREC_FASTROUND=0\n" "\n" +"[Mini Metro]\n" +"BOX64_ADDLIBS=stdc++.so.6\n" +"\n" "[pressure-vessel-wrap]\n" "BOX64_NOGTK=1\n" "\n" @@ -110,6 +113,7 @@ ENTRYBOOL(BOX64_JVM, box64_jvm) \ ENTRYBOOL(BOX64_SDL2_JGUID, box64_sdl2_jguid) \ ENTRYINT(BOX64_MALLOC_HACK, box64_malloc_hack, 0, 2, 2) \ ENTRYINTPOS(BOX64_MAXCPU, new_maxcpu) \ +ENTRYSTRING_(BOX64_ADDLIBS, new_addlibs) \ ENTRYSTRING_(BOX64_ENV, new_env) \ ENTRYSTRING_(BOX64_ENV1, new_env1) \ ENTRYSTRING_(BOX64_ENV2, new_env2) \ @@ -483,6 +487,7 @@ extern FILE* ftrace; extern char* ftrace_name; void openFTrace(const char* newtrace); void addNewEnvVar(const char* s); +void AddNewLibs(const char* libs); #ifdef DYNAREC void GatherDynarecExtensions(); #endif @@ -574,6 +579,9 @@ void ApplyParams(const char* name) AppendList(&my_context->box64_emulated_libs, param->emulated_libs, 0); printf_log(LOG_INFO, "Applying %s=%s\n", "BOX64_EMULATED_LIBS", param->emulated_libs); } + if(param->is_new_addlibs_present) { + AddNewLibs(param->new_addlibs); + } if(param->is_new_env_present) { addNewEnvVar(param->new_env); printf_log(LOG_INFO, "Applying %s=%s\n", "BOX64_ENV", param->new_env); diff --git a/src/wrapped/wrappedlibgl.c b/src/wrapped/wrappedlibgl.c index bf7a0b9a..f7d7633e 100644 --- a/src/wrapped/wrappedlibgl.c +++ b/src/wrapped/wrappedlibgl.c @@ -435,12 +435,6 @@ static void* find_glGetVkProcAddrNV_Fct(void* fct) s->resolved = 1; \ s->addr = (uintptr_t)find_glXSwapIntervalEXT_Fct(symb); \ } \ - if(!box64_wine && GetLibInternal("libgcc_s.so.1")) { \ - setNeededLibs(lib, 1, "libstdc++.so.6"); \ - } \ - -// This is a small hack to allow loading of libstdc++ as a dependancy for libGL as this is a the case with mesa. Some game, like Mini Metro on Steam don't have -// libstdc++.so.6 as a dependancy and yet needs it to run properly, rellying on other dependancies to work #include "wrappedlib_init.h" |