@@ -55,6 +55,7 @@ int box64_cefdisablegpu = 0;
5555int box64_cefdisablegpucompositor = 0 ;
5656int box64_malloc_hack = 0 ;
5757int box64_dynarec_test = 0 ;
58+ path_collection_t box64_addlibs = {0 };
5859int box64_maxcpu = 0 ;
5960int box64_maxcpu_immutable = 0 ;
6061#if defined(SD845 ) || defined(SD888 ) || defined(SD8G2 ) || defined(TEGRAX1 )
@@ -1195,6 +1196,12 @@ int GatherEnv(char*** dest, char** env, char* prog)
11951196 return 0 ;
11961197}
11971198
1199+ void AddNewLibs (const char * list )
1200+ {
1201+ AppendList (& box64_addlibs , list , 0 );
1202+ printf_log (LOG_INFO , "BOX64: Adding %s to the libs\n" , list );
1203+ }
1204+
11981205void PrintFlags () {
11991206 printf ("Environment Variables:\n" );
12001207 printf (" BOX64_PATH is the box64 version of PATH (default is '.:bin')\n" );
@@ -1369,6 +1376,9 @@ void LoadEnvVars(box64context_t *context)
13691376 printf_log (LOG_INFO , "BOX64: Disabling handling of SigILL\n" );
13701377 }
13711378 }
1379+ if (getenv ("BOX64_ADDLIBS" )) {
1380+ AddNewLibs (getenv ("BOX64_ADDLIBS" ));
1381+ }
13721382 // check BOX64_PATH and load it
13731383 LoadEnvPath (& context -> box64_path , ".:bin" , "BOX64_PATH" );
13741384 if (getenv ("PATH" ))
@@ -1834,24 +1844,23 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
18341844 printf_log (LOG_INFO , "%s " , ld_preload .paths [i ]);
18351845 printf_log (LOG_INFO , "\n" );
18361846 }
1837- } else {
1838- if (getenv ("LD_PRELOAD" )) {
1839- char * p = getenv ("LD_PRELOAD" );
1840- if (strstr (p , "libtcmalloc_minimal.so.0" ))
1841- box64_tcmalloc_minimal = 1 ;
1842- if (strstr (p , "libtcmalloc_minimal.so.4" ))
1843- box64_tcmalloc_minimal = 1 ;
1844- if (strstr (p , "libtcmalloc_minimal_debug.so.4" ))
1845- box64_tcmalloc_minimal = 1 ;
1846- if (strstr (p , "libasan.so" ))
1847- box64_tcmalloc_minimal = 1 ; // it seems Address Sanitizer doesn't handle dlsym'd malloc very well
1848- ParseList (p , & ld_preload , 0 );
1849- if (ld_preload .size && box64_log ) {
1850- printf_log (LOG_INFO , "BOX64 trying to Preload " );
1851- for (int i = 0 ; i < ld_preload .size ; ++ i )
1852- printf_log (LOG_INFO , "%s " , ld_preload .paths [i ]);
1853- printf_log (LOG_INFO , "\n" );
1854- }
1847+ }
1848+ if (getenv ("LD_PRELOAD" )) {
1849+ char * p = getenv ("LD_PRELOAD" );
1850+ if (strstr (p , "libtcmalloc_minimal.so.0" ))
1851+ box64_tcmalloc_minimal = 1 ;
1852+ if (strstr (p , "libtcmalloc_minimal.so.4" ))
1853+ box64_tcmalloc_minimal = 1 ;
1854+ if (strstr (p , "libtcmalloc_minimal_debug.so.4" ))
1855+ box64_tcmalloc_minimal = 1 ;
1856+ if (strstr (p , "libasan.so" ))
1857+ box64_tcmalloc_minimal = 1 ; // it seems Address Sanitizer doesn't handle dlsym'd malloc very well
1858+ AppendList (& ld_preload , p , 0 );
1859+ if (ld_preload .size && box64_log ) {
1860+ printf_log (LOG_INFO , "BOX64 trying to Preload " );
1861+ for (int i = 0 ; i < ld_preload .size ; ++ i )
1862+ printf_log (LOG_INFO , "%s " , ld_preload .paths [i ]);
1863+ printf_log (LOG_INFO , "\n" );
18551864 }
18561865 }
18571866 // print PATH and LD_LIB used
0 commit comments