diff options
| author | Timur Iskhodzhanov <timurrrr@google.com> | 2015-04-10 15:02:19 +0000 |
|---|---|---|
| committer | Timur Iskhodzhanov <timurrrr@google.com> | 2015-04-10 15:02:19 +0000 |
| commit | ea1f332b793f44c1100341077da5de92aa68a0af (patch) | |
| tree | ff8995bfae7bf044edb1ce16b384d6a9b53f54aa /compiler-rt/lib/sanitizer_common/sanitizer_win.cc | |
| parent | 3a09ef64ee591678a2549fe18c46e50a85cbaa5f (diff) | |
| download | bcm5719-llvm-ea1f332b793f44c1100341077da5de92aa68a0af.tar.gz bcm5719-llvm-ea1f332b793f44c1100341077da5de92aa68a0af.zip | |
Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portable
On Windows, we have to know if a memory to be protected is mapped or not.
On POSIX, Mprotect was semantically different from mprotect most people know.
llvm-svn: 234602
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_win.cc')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_win.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc index c081daa4c60..e5e2f643eb8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc @@ -125,7 +125,7 @@ void *MmapNoReserveOrDie(uptr size, const char *mem_type) { return MmapOrDie(size, mem_type); } -void *Mprotect(uptr fixed_addr, uptr size) { +void *MmapNoAccess(uptr fixed_addr, uptr size) { void *res = VirtualAlloc((LPVOID)fixed_addr, size, MEM_RESERVE | MEM_COMMIT, PAGE_NOACCESS); if (res == 0) @@ -135,6 +135,12 @@ void *Mprotect(uptr fixed_addr, uptr size) { return res; } +bool MprotectNoAccess(uptr addr, uptr size) { + DWORD old_protection; + return VirtualProtect((LPVOID)addr, size, PAGE_NOACCESS, &old_protection); +} + + void FlushUnneededShadowMemory(uptr addr, uptr size) { // This is almost useless on 32-bits. // FIXME: add madvise-analog when we move to 64-bits. |

