From eb994742669437e0e2d88b25ce367a63faf91d7a Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 10 Nov 2025 04:34:31 +0000 Subject: [PATCH] fix aarch64 gcc --- src/common/host_memory.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 02871e878a..eebb88de29 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -619,10 +619,10 @@ public: prot_flags |= PROT_READ; if (True(perms & MemoryPermission::Write)) prot_flags |= PROT_WRITE; - // W^X only supported with NCE -#if defined(ARCHITECTURE_arm64) && defined(HAS_NCE) + // W^X only supported (and needed) with NCE +#ifdef HAS_NCE if (True(perms & MemoryPermission::Execute)) - flags |= PROT_EXEC; + prot_flags |= PROT_EXEC; #endif int flags = (fd > 0 ? MAP_SHARED : MAP_PRIVATE) | MAP_FIXED; void* ret = mmap(virtual_base + virtual_offset, length, prot_flags, flags, fd, host_offset); @@ -650,16 +650,13 @@ public: AdjustMap(&virtual_offset, &length); int flags = PROT_NONE; - if (read) { + if (read) flags |= PROT_READ; - } - if (write) { + if (write) flags |= PROT_WRITE; - } #ifdef HAS_NCE - if (execute) { + if (execute) flags |= PROT_EXEC; - } #endif int ret = mprotect(virtual_base + virtual_offset, length, flags); ASSERT_MSG(ret == 0, "mprotect failed: {}", strerror(errno));