From c8147ce3d434035153fb0ab33139b52b342bf4a3 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 23 Jan 2022 16:33:00 +0100 Subject: [PATCH] Added BOX86_ALLOWMISSING_SYMBOLS option, rename BOX86_ALLOWINGLIBS, and added a special case for hl_linux (for #559) --- docs/USAGE.md | 9 +++++++-- src/include/debug.h | 1 + src/main.c | 21 +++++++++++++++++++-- src/wrapped/wrappedlibdl.c | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/USAGE.md b/docs/USAGE.md index 04984ed6..0a8bdc71 100755 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -141,11 +141,16 @@ Enable/Disable simulation of Strong Memory model Some games uses an old version of some libraries, with an ABI incompatible with native version. Note that LittleInferno for example is auto detected, and libvorbis.so.0 is automatical added to emulated libs, and same for Don't Starve (and Together / Server variant) that use an old SDL2 too -#### BOX86_ALLOWMISSINGLIBS -Allow Box86 to continue even if a library is missing. +#### BOX86_ALLOWMISSING_LIBS +Allow Box86 to continue even if a library is missing (renamed from BOX86_ALLOWMISSINGLIBS). * 0 : Box86 will stop if a library cannot be loaded. (Default.) * 1 : Continue even if a needed library cannot be loaded. Unadvised, this will, in most cases, crash later on. +#### BOX86_ALLOWMISSING_SYMBOLS +Allow dlopen with RTLD_NOW flag to not resolve all symbols. + * 0 : Box86 will stop if a library have unresolved symbols. (Default.) + * 1 : Continue even if a needed library have unresolved symbols (like symbols not yet wrapped). + #### BOX86_NOPULSE Disables the load of pulseaudio libraries. * 0 : Load pulseaudio libraries if found. (Default.) diff --git a/src/include/debug.h b/src/include/debug.h index 1d241ac6..936e795f 100755 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -30,6 +30,7 @@ extern int box86_steam; extern int box86_nopulse; // disabling the use of wrapped pulseaudio extern int box86_nogtk; // disabling the use of wrapped gtk extern int box86_novulkan; // disabling the use of wrapped vulkan +extern int allow_missing_symbols; extern uintptr_t trace_start, trace_end; extern char* trace_func; extern uintptr_t fmod_smc_start, fmod_smc_end; // to handle libfmod (from Unreal) SMC (self modifying code) diff --git a/src/main.c b/src/main.c index 59e6991b..cff48e25 100755 --- a/src/main.c +++ b/src/main.c @@ -84,6 +84,7 @@ int box86_zoom = 0; int x11threads = 0; int x11glx = 1; int allow_missing_libs = 0; +int allow_missing_symbols = 0; int fix_64bit_inodes = 0; int box86_steam = 0; int box86_nopulse = 0; @@ -418,8 +419,10 @@ void LoadLogEnv() if(libGL) { printf_log(LOG_INFO, "BOX86 using \"%s\" as libGL.so.1\n", p); } - p = getenv("BOX86_ALLOWMISSINGLIBS"); - if(p) { + p = getenv("BOX86_ALLOWMISSING_LIBS"); + if(!p) + p = getenv("BOX86_ALLOWMISSINGLIBS"); + if(p) { if(strlen(p)==1) { if(p[0]>='0' && p[0]<='0'+1) allow_missing_libs = p[0]-'0'; @@ -427,6 +430,15 @@ void LoadLogEnv() if(allow_missing_libs) printf_log(LOG_INFO, "Allow missing needed libs\n"); } + p = getenv("BOX86_ALLOWMISSING_SYMBOLS"); + if(p) { + if(strlen(p)==1) { + if(p[0]>='0' && p[0]<='0'+1) + allow_missing_symbols = p[0]-'0'; + } + if(allow_missing_symbols) + printf_log(LOG_INFO, "Allow missing needed symbols\n"); + } p = getenv("BOX86_NOPULSE"); if(p) { if(strlen(p)==1) { @@ -1067,6 +1079,11 @@ int main(int argc, const char **argv, const char **env) { printf_log(LOG_INFO, "X3Reunion detected, forcing emulated libjpeg\n"); AddPath("libjpeg.so.62", &my_context->box86_emulated_libs, 0); } + // special case for hl_linux + if(strstr(prgname, "hl_linux")==prgname) { + printf_log(LOG_INFO, "HalfLife Linux detected, allowing missing symbols\n"); + allow_missing_symbols = 1; + } /*if(strstr(prgname, "awesomium_process")==prgname) { printf_log(LOG_INFO, "awesomium_process detected, forcing emulated libpng12\n"); AddPath("libpng12.so.0", &my_context->box86_emulated_libs, 0); diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c index 5e1176b0..c2c42943 100755 --- a/src/wrapped/wrappedlibdl.c +++ b/src/wrapped/wrappedlibdl.c @@ -122,7 +122,7 @@ void* my_dlopen(x86emu_t* emu, void *filename, int flag) // Then open the lib const char* libs[] = {rfilename}; my_context->deferedInit = 1; - int bindnow = (flag&0x2)?1:0; + int bindnow = (flag&0x2 && !allow_missing_symbols)?1:0; if(AddNeededLib(NULL, NULL, NULL, is_local, bindnow, libs, 1, emu->context, emu)) { printf_log(LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); if(!dl->last_error)