|
|
|
@@ -1,17 +1,17 @@
|
|
|
|
|
From e3a9a59d25e11351bf8ff6ed0578c5defbad84ae Mon Sep 17 00:00:00 2001
|
|
|
|
|
From 79d2d9e8f181ce3d5f4ba05ae31c4c5ebf4721ed Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
|
|
|
|
Date: Mon, 12 Jun 2017 00:16:08 +0200
|
|
|
|
|
Subject: loader: Implement preloader for Mac OS.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
Makefile.in | 1 +
|
|
|
|
|
configure.ac | 32 ++++-
|
|
|
|
|
configure.ac | 30 +++-
|
|
|
|
|
dlls/ntdll/virtual.c | 2 -
|
|
|
|
|
libs/wine/config.c | 2 +-
|
|
|
|
|
loader/Makefile.in | 4 +-
|
|
|
|
|
loader/main.c | 44 ++----
|
|
|
|
|
loader/preloader.c | 386 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
|
|
7 files changed, 420 insertions(+), 51 deletions(-)
|
|
|
|
|
loader/main.c | 44 ++---
|
|
|
|
|
loader/preloader.c | 449 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
|
|
7 files changed, 480 insertions(+), 52 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/Makefile.in b/Makefile.in
|
|
|
|
|
index 22b2ae72305..29b6cbdd535 100644
|
|
|
|
@@ -26,10 +26,10 @@ index 22b2ae72305..29b6cbdd535 100644
|
|
|
|
|
LIBWINE_IMPORTLIB = @LIBWINE_IMPORTLIB@
|
|
|
|
|
LIBWINE_INSTALL_LIB = @LIBWINE_INSTALL_LIB@
|
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
|
|
|
|
index 5aaa20c22b6..433e7fa959c 100644
|
|
|
|
|
index 0f2221963dc..86c3276d28e 100644
|
|
|
|
|
--- a/configure.ac
|
|
|
|
|
+++ b/configure.ac
|
|
|
|
|
@@ -709,6 +709,7 @@ AC_SUBST(LDRPATH_INSTALL,"")
|
|
|
|
|
@@ -683,6 +683,7 @@ AC_SUBST(LDRPATH_INSTALL,"")
|
|
|
|
|
AC_SUBST(LDRPATH_LOCAL,"")
|
|
|
|
|
AC_SUBST(LDEXECFLAGS,"")
|
|
|
|
|
AC_SUBST(WINELOADER_LDFLAGS,"")
|
|
|
|
@@ -37,13 +37,13 @@ index 5aaa20c22b6..433e7fa959c 100644
|
|
|
|
|
LIBEXT="so"
|
|
|
|
|
DLLEXT=".so"
|
|
|
|
|
IMPLIBEXT="def"
|
|
|
|
|
@@ -767,9 +768,26 @@ case $host_os in
|
|
|
|
|
@@ -741,9 +742,24 @@ case $host_os in
|
|
|
|
|
AC_SUBST(APPLICATIONSERVICES_LIBS,"-framework ApplicationServices")
|
|
|
|
|
AC_SUBST(CORESERVICES_LIBS,"-framework CoreServices")
|
|
|
|
|
AC_SUBST(APPKIT_LIBS,"-framework AppKit")
|
|
|
|
|
- WINELOADER_LDFLAGS="-image_base 0x7bf00000 -Wl,-pagezero_size,0x1000,-segaddr,WINE_DOS,0x00001000,-segaddr,WINE_SHAREDHEAP,0x7f000000,-sectcreate,__TEXT,__info_plist,wine_info.plist"
|
|
|
|
|
+
|
|
|
|
|
+ WINELOADER_LDFLAGS="-Wl,-image_base,0x7bf00000,-pie,-sectcreate,__TEXT,__info_plist,wine_info.plist"
|
|
|
|
|
+ WINELOADER_LDFLAGS="-Wl,-pie,-pagezero_size,0x1000,-sectcreate,__TEXT,__info_plist,wine_info.plist"
|
|
|
|
|
+ WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
|
|
|
|
|
+ [WINELOADER_LDFLAGS="-Wl,--export-dynamic $WINELOADER_LDFLAGS"])
|
|
|
|
|
+
|
|
|
|
@@ -56,17 +56,15 @@ index 5aaa20c22b6..433e7fa959c 100644
|
|
|
|
|
+
|
|
|
|
|
+ case $host_cpu in
|
|
|
|
|
+ *i[[3456789]]86*)
|
|
|
|
|
+ WINELOADER_LDFLAGS="-Wl,-pagezero_size,0x0 $WINELOADER_LDFLAGS"
|
|
|
|
|
+ WINEPRELOADER_LDFLAGS="-Wl,-pagezero_size,0x0 $WINEPRELOADER_LDFLAGS" ;;
|
|
|
|
|
+ *x86_64*)
|
|
|
|
|
+ WINELOADER_LDFLAGS="-Wl,-pagezero_size,0x1000 $WINELOADER_LDFLAGS"
|
|
|
|
|
+ WINEPRELOADER_LDFLAGS="-Wl,-pagezero_size,0x1000 $WINEPRELOADER_LDFLAGS" ;;
|
|
|
|
|
+ esac
|
|
|
|
|
+
|
|
|
|
|
if test "$ac_cv_header_DiskArbitration_DiskArbitration_h" = "yes"
|
|
|
|
|
then
|
|
|
|
|
dnl DiskArbitration API is not public on Darwin < 8.0, use it only if header found
|
|
|
|
|
@@ -882,6 +900,7 @@ case $host_os in
|
|
|
|
|
@@ -856,6 +872,7 @@ case $host_os in
|
|
|
|
|
enable_wineandroid_drv=${enable_wineandroid_drv:-yes}
|
|
|
|
|
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
|
|
|
|
|
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
|
|
|
|
@@ -74,7 +72,7 @@ index 5aaa20c22b6..433e7fa959c 100644
|
|
|
|
|
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
|
|
|
|
|
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
|
|
|
|
|
LDRPATH_LOCAL="-Wl,--rpath,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"],
|
|
|
|
|
@@ -926,6 +945,7 @@ case $host_os in
|
|
|
|
|
@@ -900,6 +917,7 @@ case $host_os in
|
|
|
|
|
|
|
|
|
|
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
|
|
|
|
|
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
|
|
|
|
@@ -82,7 +80,7 @@ index 5aaa20c22b6..433e7fa959c 100644
|
|
|
|
|
|
|
|
|
|
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
|
|
|
|
|
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`:\$(DESTDIR)\${libdir}"
|
|
|
|
|
@@ -2085,6 +2105,14 @@ case $host_os in
|
|
|
|
|
@@ -2009,6 +2027,14 @@ case $host_os in
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
@@ -98,10 +96,10 @@ index 5aaa20c22b6..433e7fa959c 100644
|
|
|
|
|
|
|
|
|
|
dnl **** Check for functions ****
|
|
|
|
|
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
|
|
|
|
index 0d3fa1e5715..3a280a4b0d8 100644
|
|
|
|
|
index ee9c8d0195d..f115576e1db 100644
|
|
|
|
|
--- a/dlls/ntdll/virtual.c
|
|
|
|
|
+++ b/dlls/ntdll/virtual.c
|
|
|
|
|
@@ -1941,11 +1941,9 @@ void virtual_release_address_space(void)
|
|
|
|
|
@@ -1840,11 +1840,9 @@ void virtual_release_address_space(void)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@@ -114,10 +112,10 @@ index 0d3fa1e5715..3a280a4b0d8 100644
|
|
|
|
|
|
|
|
|
|
server_leave_uninterrupted_section( &csVirtual, &sigset );
|
|
|
|
|
diff --git a/libs/wine/config.c b/libs/wine/config.c
|
|
|
|
|
index 7daf38a07b5..7223ecd89cf 100644
|
|
|
|
|
index be9f401d9e7..bccb36a6c12 100644
|
|
|
|
|
--- a/libs/wine/config.c
|
|
|
|
|
+++ b/libs/wine/config.c
|
|
|
|
|
@@ -1709,7 +1709,7 @@ void wine_exec_wine_binary( const char *name, char **argv, const char *env_var )
|
|
|
|
|
@@ -654,7 +654,7 @@ void wine_exec_wine_binary( const char *name, char **argv, const char *env_var )
|
|
|
|
|
|
|
|
|
|
if (!name) name = argv0_name; /* no name means default loader */
|
|
|
|
|
|
|
|
|
@@ -224,7 +222,7 @@ index 13740c7b3c5..5212e3f0798 100644
|
|
|
|
|
|
|
|
|
|
wine_init( argc, argv, error, sizeof(error) );
|
|
|
|
|
diff --git a/loader/preloader.c b/loader/preloader.c
|
|
|
|
|
index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
index 5e6add7830f..63cf9eccb12 100644
|
|
|
|
|
--- a/loader/preloader.c
|
|
|
|
|
+++ b/loader/preloader.c
|
|
|
|
|
@@ -4,6 +4,8 @@
|
|
|
|
@@ -257,12 +255,22 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
#ifndef MAP_COPY
|
|
|
|
|
#define MAP_COPY MAP_PRIVATE
|
|
|
|
|
#endif
|
|
|
|
|
@@ -117,12 +118,25 @@ static struct wine_preload_info preload_info[] =
|
|
|
|
|
@@ -109,7 +110,8 @@
|
|
|
|
|
static struct wine_preload_info preload_info[] =
|
|
|
|
|
{
|
|
|
|
|
#ifdef __i386__
|
|
|
|
|
- { (void *)0x00000000, 0x00010000 }, /* low 64k */
|
|
|
|
|
+ { (void *)0x00000000, 0x00001000 }, /* first page */
|
|
|
|
|
+ { (void *)0x00001000, 0x0000f000 }, /* low 64k */
|
|
|
|
|
{ (void *)0x00010000, 0x00100000 }, /* DOS area */
|
|
|
|
|
{ (void *)0x00110000, 0x67ef0000 }, /* low memory area */
|
|
|
|
|
{ (void *)0x7f000000, 0x03000000 }, /* top-down allocations + shared heap + virtual heap */
|
|
|
|
|
@@ -117,12 +119,38 @@ static struct wine_preload_info preload_info[] =
|
|
|
|
|
{ (void *)0x000000010000, 0x00100000 }, /* DOS area */
|
|
|
|
|
{ (void *)0x000000110000, 0x67ef0000 }, /* low memory area */
|
|
|
|
|
{ (void *)0x00007ff00000, 0x000f0000 }, /* shared user data */
|
|
|
|
|
+#ifdef __APPLE__
|
|
|
|
|
+ /* address below exceeds maximum allowed user space address in mac os */
|
|
|
|
|
+ /* address below exceeds maximum allowed user space address in macOS */
|
|
|
|
|
+ { (void *)0x7fff40000000, 0x01ff0000 }, /* top-down allocations + virtual heap */
|
|
|
|
|
+#else
|
|
|
|
|
{ (void *)0x7ffffe000000, 0x01ff0000 }, /* top-down allocations + virtual heap */
|
|
|
|
@@ -272,7 +280,20 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
{ 0, 0 } /* end of list */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
+#ifndef __APPLE__
|
|
|
|
|
+#ifdef __APPLE__
|
|
|
|
|
+
|
|
|
|
|
+#ifndef LC_MAIN
|
|
|
|
|
+#define LC_MAIN 0x80000028
|
|
|
|
|
+struct entry_point_command
|
|
|
|
|
+{
|
|
|
|
|
+ uint32_t cmd;
|
|
|
|
|
+ uint32_t cmdsize;
|
|
|
|
|
+ uint64_t entryoff;
|
|
|
|
|
+ uint64_t stacksize;
|
|
|
|
|
+};
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#else /* __APPLE__ */
|
|
|
|
|
+
|
|
|
|
|
+/* ELF definitions */
|
|
|
|
|
+#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) (mapstartpref)
|
|
|
|
@@ -283,22 +304,23 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
/* debugging */
|
|
|
|
|
#undef DUMP_SEGMENTS
|
|
|
|
|
#undef DUMP_AUX_INFO
|
|
|
|
|
@@ -168,6 +182,8 @@ struct wld_auxv
|
|
|
|
|
@@ -168,6 +196,8 @@ struct wld_auxv
|
|
|
|
|
} a_un;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
+#endif /* !__APPLE__ */
|
|
|
|
|
+#endif /* __APPLE__ */
|
|
|
|
|
+
|
|
|
|
|
/*
|
|
|
|
|
* The __bb_init_func is an empty function only called when file is
|
|
|
|
|
* compiled with gcc flags "-fprofile-arcs -ftest-coverage". This
|
|
|
|
|
@@ -182,6 +198,196 @@ void *__stack_chk_guard = 0;
|
|
|
|
|
@@ -182,6 +212,201 @@ void *__stack_chk_guard = 0;
|
|
|
|
|
void __stack_chk_fail_local(void) { return; }
|
|
|
|
|
void __stack_chk_fail(void) { return; }
|
|
|
|
|
|
|
|
|
|
+#ifdef __APPLE__
|
|
|
|
|
+#ifdef __i386__
|
|
|
|
|
+
|
|
|
|
|
+static const size_t page_size = 0x1000;
|
|
|
|
|
+static const size_t page_mask = 0xfff;
|
|
|
|
|
+#define TARGET_CPU_TYPE CPU_TYPE_X86
|
|
|
|
|
+#define TARGET_MH_MAGIC MH_MAGIC
|
|
|
|
@@ -388,6 +410,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
+
|
|
|
|
|
+#elif defined(__x86_64__)
|
|
|
|
|
+
|
|
|
|
|
+static const size_t page_size = 0x1000;
|
|
|
|
|
+static const size_t page_mask = 0xfff;
|
|
|
|
|
+#define TARGET_CPU_TYPE CPU_TYPE_X86_64
|
|
|
|
|
+#define TARGET_MH_MAGIC MH_MAGIC_64
|
|
|
|
@@ -485,11 +508,14 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
+void *wld_munmap( void *start, size_t len );
|
|
|
|
|
+SYSCALL_FUNC( wld_munmap, 73 /* SYS_munmap */ );
|
|
|
|
|
+
|
|
|
|
|
+int wld_mincore( void *addr, size_t length, unsigned char *vec );
|
|
|
|
|
+SYSCALL_FUNC( wld_mincore, 78 /* SYS_mincore */ );
|
|
|
|
|
+
|
|
|
|
|
+#else /* __APPLE__ */
|
|
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
|
|
/* data for setting up the glibc-style thread-local storage in %gs */
|
|
|
|
|
@@ -458,16 +664,17 @@ SYSCALL_NOERR( wld_getegid, 108 /* SYS_getegid */ );
|
|
|
|
|
@@ -458,16 +683,17 @@ SYSCALL_NOERR( wld_getegid, 108 /* SYS_getegid */ );
|
|
|
|
|
#else
|
|
|
|
|
#error preloader not implemented for this CPU
|
|
|
|
|
#endif
|
|
|
|
@@ -509,7 +535,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
{
|
|
|
|
|
if (len <= 0) return 0;
|
|
|
|
|
while ((--len > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
|
|
|
|
|
@@ -560,6 +767,8 @@ static __attribute__((noreturn,format(printf,1,2))) void fatal_error(const char
|
|
|
|
|
@@ -560,6 +786,8 @@ static __attribute__((noreturn,format(printf,1,2))) void fatal_error(const char
|
|
|
|
|
wld_exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -518,7 +544,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
#ifdef DUMP_AUX_INFO
|
|
|
|
|
/*
|
|
|
|
|
* Dump interesting bits of the ELF auxv_t structure that is passed
|
|
|
|
|
@@ -1039,6 +1248,8 @@ found:
|
|
|
|
|
@@ -1039,6 +1267,8 @@ found:
|
|
|
|
|
return (void *)(symtab[idx].st_value + map->l_addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -527,7 +553,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
/*
|
|
|
|
|
* preload_reserve
|
|
|
|
|
*
|
|
|
|
|
@@ -1070,6 +1281,7 @@ static void preload_reserve( const char *str )
|
|
|
|
|
@@ -1070,6 +1300,7 @@ static void preload_reserve( const char *str )
|
|
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
|
if (end <= start) start = end = NULL;
|
|
|
|
@@ -535,7 +561,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
else if ((char *)end > preloader_start &&
|
|
|
|
|
(char *)start <= preloader_end)
|
|
|
|
|
{
|
|
|
|
|
@@ -1077,6 +1289,7 @@ static void preload_reserve( const char *str )
|
|
|
|
|
@@ -1077,6 +1308,7 @@ static void preload_reserve( const char *str )
|
|
|
|
|
start, end, preloader_start, preloader_end );
|
|
|
|
|
start = end = NULL;
|
|
|
|
|
}
|
|
|
|
@@ -543,7 +569,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
|
|
|
|
|
/* check for overlap with low memory areas */
|
|
|
|
|
for (i = 0; preload_info[i].size; i++)
|
|
|
|
|
@@ -1101,7 +1314,7 @@ error:
|
|
|
|
|
@@ -1101,7 +1333,7 @@ error:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* check if address is in one of the reserved ranges */
|
|
|
|
@@ -552,7 +578,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
@@ -1125,6 +1338,159 @@ static void remove_preload_range( int i )
|
|
|
|
|
@@ -1125,6 +1357,201 @@ static void remove_preload_range( int i )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -625,6 +651,55 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+static int is_region_empty( struct wine_preload_info *info )
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned char vec[1024];
|
|
|
|
|
+ size_t pos, size, block = 1024 * page_size;
|
|
|
|
|
+ int i;
|
|
|
|
|
+
|
|
|
|
|
+ for (pos = 0; pos < info->size; pos += size)
|
|
|
|
|
+ {
|
|
|
|
|
+ size = (pos + block <= info->size) ? block : (info->size - pos);
|
|
|
|
|
+ if (wld_mincore( (char *)info->addr + pos, size, vec ) == -1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (size <= page_size) continue;
|
|
|
|
|
+ block = page_size; size = 0; /* retry with smaller block size */
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ for (i = 0; i < size / page_size; i++)
|
|
|
|
|
+ if (vec[i] & 1) return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int map_region( struct wine_preload_info *info )
|
|
|
|
|
+{
|
|
|
|
|
+ int flags = MAP_PRIVATE | MAP_ANON;
|
|
|
|
|
+ void *ret;
|
|
|
|
|
+
|
|
|
|
|
+ if (!info->addr) flags |= MAP_FIXED;
|
|
|
|
|
+
|
|
|
|
|
+ for (;;)
|
|
|
|
|
+ {
|
|
|
|
|
+ ret = wld_mmap( info->addr, info->size, PROT_NONE, flags, -1, 0 );
|
|
|
|
|
+ if (ret == info->addr) return 1;
|
|
|
|
|
+ if (ret != (void *)-1) wld_munmap( ret, info->size );
|
|
|
|
|
+ if (flags & MAP_FIXED) break;
|
|
|
|
|
+
|
|
|
|
|
+ /* Some versions of macOS ignore the address hint passed to mmap -
|
|
|
|
|
+ * use mincore() to check if its empty and then use MAP_FIXED */
|
|
|
|
|
+ if (!is_region_empty( info )) break;
|
|
|
|
|
+ flags |= MAP_FIXED;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ wld_printf( "preloader: Warning: failed to reserve range %p-%p\n",
|
|
|
|
|
+ info->addr, (char *)info->addr + info->size );
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static inline void get_dyld_func( const char *name, void **func )
|
|
|
|
|
+{
|
|
|
|
|
+ _dyld_func_lookup( name, func );
|
|
|
|
@@ -636,6 +711,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
+
|
|
|
|
|
+void *wld_start( void *stack, int *is_unix_thread )
|
|
|
|
|
+{
|
|
|
|
|
+ struct wine_preload_info builtin_dlls = { (void *)0x7a000000, 0x02000000 };
|
|
|
|
|
+ struct wine_preload_info **wine_main_preload_info;
|
|
|
|
|
+ char **argv, **p, *reserve = NULL;
|
|
|
|
|
+ struct target_mach_header *mh;
|
|
|
|
@@ -662,27 +738,16 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
+ if (reserve) preload_reserve( reserve );
|
|
|
|
|
+ for (i = 0; preload_info[i].size; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ int flags = MAP_PRIVATE | MAP_ANON;
|
|
|
|
|
+ void *ret;
|
|
|
|
|
+
|
|
|
|
|
+ if (!preload_info[i].addr)
|
|
|
|
|
+ flags |= MAP_FIXED;
|
|
|
|
|
+
|
|
|
|
|
+ ret = wld_mmap( preload_info[i].addr, preload_info[i].size, PROT_NONE, flags, -1, 0 );
|
|
|
|
|
+ if (ret != (void *)-1 && ret != preload_info[i].addr)
|
|
|
|
|
+ if (!map_region( &preload_info[i] ))
|
|
|
|
|
+ {
|
|
|
|
|
+ wld_munmap(ret, preload_info[i].size);
|
|
|
|
|
+ ret = (void *)-1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ret == (void *)-1)
|
|
|
|
|
+ {
|
|
|
|
|
+ wld_printf( "preloader: Warning: failed to reserve range %p-%p\n",
|
|
|
|
|
+ preload_info[i].addr, (char *)preload_info[i].addr + preload_info[i].size );
|
|
|
|
|
+ remove_preload_range( i );
|
|
|
|
|
+ i--;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!map_region( &builtin_dlls ))
|
|
|
|
|
+ builtin_dlls.size = 0;
|
|
|
|
|
+
|
|
|
|
|
+ LOAD_POSIX_DYLD_FUNC( dlopen );
|
|
|
|
|
+ LOAD_POSIX_DYLD_FUNC( dlsym );
|
|
|
|
|
+ LOAD_MACHO_DYLD_FUNC( _dyld_image_count );
|
|
|
|
@@ -693,6 +758,9 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
+ if (!(mod = pdlopen( argv[1], RTLD_NOW )))
|
|
|
|
|
+ fatal_error( "%s: could not load binary\n", argv[1] );
|
|
|
|
|
+
|
|
|
|
|
+ if (builtin_dlls.size)
|
|
|
|
|
+ wld_munmap( builtin_dlls.addr, builtin_dlls.size );
|
|
|
|
|
+
|
|
|
|
|
+ /* store pointer to the preload info into the appropriate main binary variable */
|
|
|
|
|
+ wine_main_preload_info = pdlsym( mod, "wine_main_preload_info" );
|
|
|
|
|
+ if (wine_main_preload_info) *wine_main_preload_info = preload_info;
|
|
|
|
@@ -712,7 +780,7 @@ index 5e6add7830f..b3e80527309 100644
|
|
|
|
|
/*
|
|
|
|
|
* is_in_preload_range
|
|
|
|
|
*
|
|
|
|
|
@@ -1293,3 +1659,5 @@ void* wld_start( void **stack )
|
|
|
|
|
@@ -1293,3 +1720,5 @@ void* wld_start( void **stack )
|
|
|
|
|
|
|
|
|
|
return (void *)ld_so_map.l_entry;
|
|
|
|
|
}
|
|
|
|
|