# HG changeset patch # User David Major # Date 1550007886 0 # Node ID 430f461b9636bc0efe20e52f5bce16e7c0e063c5 # Parent 91ac960f7b59bad97277da550775df1e14a6c9fb Bug 1525416 - Teach libffi/src/closures.c about ARM64_WIN64 r=froydnj I added ARM64_WIN64 to every line that mentioned X86_WIN32 and X86_WIN64. This makes sure the allocation routines do the proper VirtualProtect on the trampolines. Differential Revision: https://phabricator.services.mozilla.com/D19567 diff --git a/js/src/ctypes/libffi/src/closures.c b/js/src/ctypes/libffi/src/closures.c --- a/js/src/ctypes/libffi/src/closures.c +++ b/js/src/ctypes/libffi/src/closures.c @@ -40,17 +40,17 @@ option is defined will attempt to map such pages once, but if it fails, it falls back to creating a temporary file in a writable and executable filesystem and mapping pages from it into separate locations in the virtual memory space, one location writable and another executable. */ # define FFI_MMAP_EXEC_WRIT 1 # define HAVE_MNTENT 1 # endif -# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__) +# if defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__) /* Windows systems may have Data Execution Protection (DEP) enabled, which requires the use of VirtualMalloc/VirtualFree to alloc/free executable memory. */ # define FFI_MMAP_EXEC_WRIT 1 # endif #endif #if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX @@ -106,17 +106,17 @@ #include #include #include #ifndef _MSC_VER #include #endif #include #include -#if !defined(X86_WIN32) && !defined(X86_WIN64) +#if !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(ARM64_WIN64) #ifdef HAVE_MNTENT #include #endif /* HAVE_MNTENT */ #include #include /* We don't want sys/mman.h to be included after we redefine mmap and dlmunmap. */ @@ -209,17 +209,17 @@ emutramp_enabled_check (void) #elif defined (__CYGWIN__) || defined(__INTERIX) #include /* Cygwin is Linux-like, but not quite that Linux-like. */ #define is_selinux_enabled() 0 -#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ +#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(ARM64_WIN64) */ #ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX #define is_emutramp_enabled() 0 #endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */ /* Declare all functions defined in dlmalloc.c as static. */ static void *dlmalloc(size_t); static void dlfree(void*); @@ -232,31 +232,31 @@ static size_t dlmalloc_footprint(void) M static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED; static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED; static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED; static void *dlpvalloc(size_t) MAYBE_UNUSED; static int dlmalloc_trim(size_t) MAYBE_UNUSED; static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED; static void dlmalloc_stats(void) MAYBE_UNUSED; -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) /* Use these for mmap and munmap within dlmalloc.c. */ static void *dlmmap(void *, size_t, int, int, int, off_t); static int dlmunmap(void *, size_t); -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ #define mmap dlmmap #define munmap dlmunmap #include "dlmalloc.c" #undef mmap #undef munmap -#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) /* A mutex used to synchronize access to *exec* variables in this file. */ static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER; /* A file descriptor of a temporary file from which we'll map executable pages. */ static int execfd = -1; @@ -567,17 +567,17 @@ segment_holding_code (mstate m, char* ad && addr < add_segment_exec_offset (sp->base, sp) + sp->size) return sp; if ((sp = sp->next) == 0) return 0; } } #endif -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */ /* Allocate a chunk of memory with the given size. Returns a pointer to the writable address, and sets *CODE to the executable corresponding virtual address. */ void * ffi_closure_alloc (size_t size, void **code) { void *ptr;