From 5e1f189db32431f5bef414f7f7c7331e1ccf61ee Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 13 Jul 2022 19:23:45 +0300 Subject: [PATCH] engine: platform: posix: use RTLD_NOW instead of lazy. It actually was a misconception coming from old engine fork We want to track unresolved symbols before library could be loaded Also, disable "symbol not found" spam in FunctionFromName. Due to how savefile mangling convert works and compatibility with GoldSrc saves, this function is used to bruteforce possible symbol names. --- engine/platform/posix/lib_posix.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/engine/platform/posix/lib_posix.c b/engine/platform/posix/lib_posix.c index c4026706..abfd46ad 100644 --- a/engine/platform/posix/lib_posix.c +++ b/engine/platform/posix/lib_posix.c @@ -102,7 +102,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d // try to find by linker(LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, LD_32_LIBRARY_PATH and so on...) if( !pHandle ) { - pHandle = dlopen( dllname, RTLD_LAZY ); + pHandle = dlopen( dllname, RTLD_NOW ); if( pHandle ) return pHandle; @@ -139,7 +139,7 @@ void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean d else #endif { - if( !( hInst->hInstance = dlopen( hInst->fullPath, RTLD_LAZY ) ) ) + if( !( hInst->hInstance = dlopen( hInst->fullPath, RTLD_NOW ) ) ) { COM_PushLibraryError( dlerror() ); Mem_Free( hInst ); @@ -188,12 +188,7 @@ void *COM_GetProcAddress( void *hInstance, const char *name ) void *COM_FunctionFromName( void *hInstance, const char *pName ) { - void *function; - if( !( function = COM_GetProcAddress( hInstance, pName ) ) ) - { - Con_Reportf( S_ERROR "FunctionFromName: Can't get symbol %s: %s\n", pName, dlerror()); - } - return function; + return COM_GetProcAddress( hInstance, pName ); } #ifdef XASH_DYNAMIC_DLADDR