From: Davide Italiano Date: Tue, 17 Nov 2015 16:34:28 +0000 (+0000) Subject: [JIT/Memory] Fix up semantic of setExecutable(). X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=fa084bd00c2affb7b94766f2e5b06b953e959ab8 [JIT/Memory] Fix up semantic of setExecutable(). setExecutable() should do everything that's needed to make the memory executable on host, i.e. unconditionally set permissions + invalidate instruction cache. llvm-rtdyld will be updated in my next commit. Discusseed with: Lang Hames (as part of D13631). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253341 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Unix/Memory.inc b/lib/Support/Unix/Memory.inc index 4c66b8a01b0..7bffdf38773 100644 --- a/lib/Support/Unix/Memory.inc +++ b/lib/Support/Unix/Memory.inc @@ -264,15 +264,12 @@ bool Memory::setWritable (MemoryBlock &M, std::string *ErrMsg) { } bool Memory::setExecutable (MemoryBlock &M, std::string *ErrMsg) { -#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) if (M.Address == 0 || M.Size == 0) return false; Memory::InvalidateInstructionCache(M.Address, M.Size); +#if defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)M.Address, (vm_size_t)M.Size, 0, VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY); return KERN_SUCCESS == kr; -#elif defined(__arm__) || defined(__aarch64__) - Memory::InvalidateInstructionCache(M.Address, M.Size); - return true; #else return true; #endif