diff options
author | Simon Hausmann <[email protected]> | 2016-08-12 16:05:34 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2016-08-17 14:05:18 +0000 |
commit | 9fcca80bc4682fd274d2e4d8014390962dab5daa (patch) | |
tree | c9562bed09a476acea77ffd76259e0bfda5f7e2f /src/qml/compiler/qv4compilationunitmapper_win.cpp | |
parent | 9132b7731c5e2b418d240bac998a10112be50938 (diff) |
Make the unit mapping on Windows configurable with regards to executable mapping
If we generate byte code, then we can mmap without the executable flags,
otherwise we need them. This should make things work out of the box on
platforms where special rights are needed before executable mappings are
allowed.
Change-Id: I24e663f85d661bc51cd3bf2463547b1d1590ea32
Reviewed-by: Maurice Kalinowski <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4compilationunitmapper_win.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilationunitmapper_win.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compilationunitmapper_win.cpp b/src/qml/compiler/qv4compilationunitmapper_win.cpp index 7e62cbfe8b..6c2f36e7a0 100644 --- a/src/qml/compiler/qv4compilationunitmapper_win.cpp +++ b/src/qml/compiler/qv4compilationunitmapper_win.cpp @@ -94,9 +94,14 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co if (!verifyHeader(&header, sourcePath, errorString)) return nullptr; + const uint mappingFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode + ? PAGE_EXECUTE_READ : PAGE_READONLY; + const uint viewFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode + ? (FILE_MAP_READ | FILE_MAP_EXECUTE) : FILE_MAP_READ; + // Data structure and qt version matched, so now we can access the rest of the file safely. - HANDLE fileMappingHandle = CreateFileMapping(handle, 0, PAGE_EXECUTE_READ, 0, 0, 0); + HANDLE fileMappingHandle = CreateFileMapping(handle, 0, mappingFlags, 0, 0, 0); if (!fileMappingHandle) { *errorString = qt_error_string(GetLastError()); return false; @@ -106,7 +111,7 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co CloseHandle(fileMappingHandle); }); - dataPtr = MapViewOfFile(fileMappingHandle, FILE_MAP_READ | FILE_MAP_EXECUTE, 0, 0, 0); + dataPtr = MapViewOfFile(fileMappingHandle, viewFlags, 0, 0, 0); if (!dataPtr) { *errorString = qt_error_string(GetLastError()); return nullptr; |