Call FlushInstrucitonCache() when PROT_EXEC is specified to mprotect

This commit is contained in:
U.Nakamura 2021-12-27 16:38:29 +09:00
parent 85a426dc86
commit 9790f54bff

View File

@ -812,8 +812,19 @@ extern int rb_w32_munmap(void *, size_t);
extern int rb_w32_mprotect(void *, size_t, int);
#define mmap(a, l, p, f, d, o) rb_w32_mmap(a, l, p, f, d, o)
#define munmap(a, l) rb_w32_munmap(a. l)
#define mprotect(a, l, p) 0
#define munmap(a, l) rb_w32_munmap(a, l)
static inline int
mprotect(void *addr, size_t len, int prot)
{
if (prot | PROT_EXEC) {
if (!FlushInstructionCache(GetCurrentProcess(), addr, len)) {
errno = rb_w32_map_errno(GetLastError());
return -1;
}
}
return 0;
}
#if defined(__cplusplus)
#if 0