Skip to content

Commit c609773

Browse files
committed
Add LD Loader Root Path Environment
1 parent ae5e029 commit c609773

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

loader/preloader.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,12 @@ SYSCALL_NOERR( wld_getegid, 177 /* SYS_getegid */ );
541541

542542
/* replacement for libc functions */
543543

544+
static int wld_strcat(char *dest, const char *src)
545+
{
546+
while (*dest) dest ++;
547+
while (*src) { * dest = * src; dest ++; src ++; }
548+
}
549+
544550
static int wld_strcmp( const char *str1, const char *str2 )
545551
{
546552
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
@@ -1255,7 +1261,7 @@ void* wld_start( void **stack )
12551261
{
12561262
long i, *pargc;
12571263
char **argv, **p;
1258-
char *interp, *reserve = NULL;
1264+
char *interp, *reserve, *rootpath = NULL;
12591265
struct wld_auxv new_av[8], delete_av[3], *av;
12601266
struct wld_link_map main_binary_map, ld_so_map;
12611267
struct wine_preload_info **wine_main_preload_info;
@@ -1272,6 +1278,10 @@ void* wld_start( void **stack )
12721278
{
12731279
static const char res[] = "WINEPRELOADRESERVE=";
12741280
if (!wld_strncmp( *p, res, sizeof(res)-1 )) reserve = *p + sizeof(res) - 1;
1281+
1282+
static const char root[] = "LINUXFILEROOT=";
1283+
if (!wld_strncmp( *p, root, sizeof(root)-1 )) rootpath = *p + sizeof(root) - 1;
1284+
12751285
p++;
12761286
}
12771287

@@ -1324,7 +1334,16 @@ void* wld_start( void **stack )
13241334

13251335
/* load the ELF interpreter */
13261336
interp = (char *)main_binary_map.l_addr + main_binary_map.l_interp;
1327-
map_so_lib( interp, &ld_so_map );
1337+
1338+
char fullpath[256] = {};
1339+
wld_memset(fullpath, 0, sizeof(fullpath));
1340+
1341+
if (rootpath != NULL)
1342+
wld_strcat(fullpath, rootpath);
1343+
1344+
wld_strcat(fullpath, interp);
1345+
1346+
map_so_lib( fullpath, &ld_so_map );
13281347

13291348
/* store pointer to the preload info into the appropriate main binary variable */
13301349
wine_main_preload_info = find_symbol( &main_binary_map, "wine_main_preload_info", STT_OBJECT );

0 commit comments

Comments
 (0)