fix aarch64 gcc

This commit is contained in:
lizzie 2025-11-10 04:34:31 +00:00
parent 019921c10a
commit bf56de094b

View file

@ -619,10 +619,10 @@ public:
prot_flags |= PROT_READ; prot_flags |= PROT_READ;
if (True(perms & MemoryPermission::Write)) if (True(perms & MemoryPermission::Write))
prot_flags |= PROT_WRITE; prot_flags |= PROT_WRITE;
// W^X only supported with NCE // W^X only supported (and needed) with NCE
#if defined(ARCHITECTURE_arm64) && defined(HAS_NCE) #ifdef HAS_NCE
if (True(perms & MemoryPermission::Execute)) if (True(perms & MemoryPermission::Execute))
flags |= PROT_EXEC; prot_flags |= PROT_EXEC;
#endif #endif
int flags = (fd > 0 ? MAP_SHARED : MAP_PRIVATE) | MAP_FIXED; int flags = (fd > 0 ? MAP_SHARED : MAP_PRIVATE) | MAP_FIXED;
void* ret = mmap(virtual_base + virtual_offset, length, prot_flags, flags, fd, host_offset); void* ret = mmap(virtual_base + virtual_offset, length, prot_flags, flags, fd, host_offset);
@ -650,16 +650,13 @@ public:
AdjustMap(&virtual_offset, &length); AdjustMap(&virtual_offset, &length);
int flags = PROT_NONE; int flags = PROT_NONE;
if (read) { if (read)
flags |= PROT_READ; flags |= PROT_READ;
} if (write)
if (write) {
flags |= PROT_WRITE; flags |= PROT_WRITE;
}
#ifdef HAS_NCE #ifdef HAS_NCE
if (execute) { if (execute)
flags |= PROT_EXEC; flags |= PROT_EXEC;
}
#endif #endif
int ret = mprotect(virtual_base + virtual_offset, length, flags); int ret = mprotect(virtual_base + virtual_offset, length, flags);
ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno)); ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno));