Index: external/bsd/llvm/librt/libLLVMSupport/../../lib/../dist/llvm/lib/Support/Unix/Memory.inc =================================================================== RCS file: /cvsroot/src/external/bsd/llvm/dist/llvm/lib/Support/Unix/Memory.inc,v retrieving revision 1.1.1.9 diff -p -u -r1.1.1.9 Memory.inc --- external/bsd/llvm/librt/libLLVMSupport/../../lib/../dist/llvm/lib/Support/Unix/Memory.inc 17 Jul 2018 18:33:35 -0000 1.1.1.9 +++ external/bsd/llvm/librt/libLLVMSupport/../../lib/../dist/llvm/lib/Support/Unix/Memory.inc 7 Jun 2019 11:18:48 -0000 @@ -174,8 +174,12 @@ Memory::protectMappedMemory(const Memory // Certain ARM implementations treat icache clear instruction as a memory read, // and CPU segfaults on trying to clear cache on !PROT_READ page. Therefore we need // to temporarily add PROT_READ for the sake of flushing the instruction caches. - if (InvalidateCache && !(Protect & PROT_READ)) { - int Result = ::mprotect((void *)Start, End - Start, Protect | PROT_READ); + int ExtraProtect = PROT_READ; +#ifdef __NetBSD__ + ExtraProtect |= PROT_WRITE; +#endif + if (InvalidateCache && (Protect & ExtraProtect) != ExtraProtect) { + int Result = ::mprotect((void *)Start, End - Start, Protect | ExtraProtect); if (Result != 0) return std::error_code(errno, std::generic_category());