Commit e745f5a9 by Nicolas Capens

Set permissions after loading image.

Bug b/38514001 Change-Id: I6d2d891545840beee54db95a7456b6ede293d0eb Reviewed-on: https://swiftshader-review.googlesource.com/9908Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent b89010fa
...@@ -492,20 +492,16 @@ namespace sw ...@@ -492,20 +492,16 @@ namespace sw
{ {
if(!entry) if(!entry)
{ {
#if defined(_WIN32)
VirtualProtect(&buffer[0], buffer.size(), PAGE_EXECUTE_READWRITE, &oldProtection);
#else
mprotect(&buffer[0], buffer.size(), PROT_READ | PROT_WRITE | PROT_EXEC);
#endif
position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this
size_t codeSize = 0; size_t codeSize = 0;
entry = loadImage(&buffer[0], codeSize); entry = loadImage(&buffer[0], codeSize);
#if defined(_WIN32) #if defined(_WIN32)
VirtualProtect(&buffer[0], buffer.size(), PAGE_EXECUTE_READ, &oldProtection);
FlushInstructionCache(GetCurrentProcess(), NULL, 0); FlushInstructionCache(GetCurrentProcess(), NULL, 0);
#else #else
mprotect(&buffer[0], buffer.size(), PROT_READ | PROT_EXEC);
__builtin___clear_cache((char*)entry, (char*)entry + codeSize); __builtin___clear_cache((char*)entry, (char*)entry + codeSize);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment