2017-07-13 07:29:21 +08:00
|
|
|
//===-- sanitizer_mac_libcdep.cc ------------------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-07-13 07:29:21 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is shared between various sanitizers' runtime libraries and
|
|
|
|
// implements OSX-specific functions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "sanitizer_platform.h"
|
|
|
|
#if SANITIZER_MAC
|
|
|
|
#include "sanitizer_mac.h"
|
|
|
|
|
2018-08-30 03:41:28 +08:00
|
|
|
#include <sys/mman.h>
|
|
|
|
|
2017-07-13 07:29:21 +08:00
|
|
|
namespace __sanitizer {
|
|
|
|
|
|
|
|
void RestrictMemoryToMaxAddress(uptr max_address) {
|
2017-11-08 07:51:22 +08:00
|
|
|
uptr size_to_mmap = GetMaxUserVirtualAddress() + 1 - max_address;
|
2017-07-13 07:29:21 +08:00
|
|
|
void *res = MmapFixedNoAccess(max_address, size_to_mmap, "high gap");
|
2018-08-30 03:41:28 +08:00
|
|
|
CHECK(res != MAP_FAILED);
|
2017-07-13 07:29:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace __sanitizer
|
|
|
|
|
|
|
|
#endif // SANITIZER_MAC
|