[PATCH v2 1/3] loader: Fix building of the preloader on Mac.

Ken Thomases ken at codeweavers.com
Wed Dec 5 15:41:04 CST 2018


Don't reference the Linux-specific variables preloader_start and preloader_end
in the shared code.

Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
v2: Avoid a platform #ifdef in the shared code
    Set up infrastructure for eventual implementation of overlap check on Mac


 loader/preloader.c     | 19 ++++++++++++-------
 loader/preloader.h     |  1 +
 loader/preloader_mac.c |  5 +++++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/loader/preloader.c b/loader/preloader.c
index 3b1f5ad..9f2fbc3 100644
--- a/loader/preloader.c
+++ b/loader/preloader.c
@@ -1049,6 +1049,17 @@ static int is_in_preload_range( const struct wld_auxv *av, int type )
     return 0;
 }
 
+int preloader_overlaps_range( const void *start, const void *end )
+{
+    if ((char *)end > preloader_start && (char *)start <= preloader_end)
+    {
+        wld_printf( "WINEPRELOADRESERVE range %p-%p overlaps preloader %p-%p\n",
+                     start, end, preloader_start, preloader_end );
+        return 1;
+    }
+    return 0;
+}
+
 /* set the process name if supported */
 static void set_process_name( int argc, char *argv[] )
 {
@@ -1316,14 +1327,8 @@ void preload_reserve( const char *str, struct wine_preload_info *preload_info, s
     else if (result) goto error;  /* single value '0' is allowed */
 
     /* sanity checks */
-    if (end <= start) start = end = NULL;
-    else if ((char *)end > preloader_start &&
-             (char *)start <= preloader_end)
-    {
-        wld_printf( "WINEPRELOADRESERVE range %p-%p overlaps preloader %p-%p\n",
-                     start, end, preloader_start, preloader_end );
+    if (end <= start || preloader_overlaps_range(start, end))
         start = end = NULL;
-    }
 
     /* check for overlap with low memory areas */
     for (i = 0; preload_info[i].size; i++)
diff --git a/loader/preloader.h b/loader/preloader.h
index 2c2262e..b944a09 100644
--- a/loader/preloader.h
+++ b/loader/preloader.h
@@ -51,6 +51,7 @@ extern __attribute__((format(printf,1,2))) void wld_printf(const char *fmt, ...
 extern __attribute__((noreturn,format(printf,1,2))) void fatal_error(const char *fmt, ... );
 
 extern void preload_reserve( const char *str, struct wine_preload_info *preload_info, size_t page_mask );
+extern int preloader_overlaps_range( const void *start, const void *end );
 
 /* remove a range from the preload list */
 static inline void remove_preload_range( int i, struct wine_preload_info *preload_info )
diff --git a/loader/preloader_mac.c b/loader/preloader_mac.c
index d008270..5e9f9fc 100644
--- a/loader/preloader_mac.c
+++ b/loader/preloader_mac.c
@@ -374,6 +374,11 @@ static int map_region( struct wine_preload_info *info )
     return 0;
 }
 
+int preloader_overlaps_range( const void *start, const void *end )
+{
+    return 0;
+}
+
 static inline void get_dyld_func( const char *name, void **func )
 {
     _dyld_func_lookup( name, func );
-- 
2.10.2




More information about the wine-devel mailing list