xref: /openbsd-src/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_mac_libcdep.cpp (revision 810390e339a5425391477d5d41c78d7cab2424ac)
13cab2bb3Spatrick //===-- sanitizer_mac_libcdep.cpp -----------------------------------------===//
23cab2bb3Spatrick //
33cab2bb3Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
43cab2bb3Spatrick // See https://llvm.org/LICENSE.txt for license information.
53cab2bb3Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
63cab2bb3Spatrick //
73cab2bb3Spatrick //===----------------------------------------------------------------------===//
83cab2bb3Spatrick //
93cab2bb3Spatrick // This file is shared between various sanitizers' runtime libraries and
103cab2bb3Spatrick // implements OSX-specific functions.
113cab2bb3Spatrick //===----------------------------------------------------------------------===//
123cab2bb3Spatrick 
133cab2bb3Spatrick #include "sanitizer_platform.h"
14*810390e3Srobert #if SANITIZER_APPLE
153cab2bb3Spatrick #include "sanitizer_mac.h"
163cab2bb3Spatrick 
173cab2bb3Spatrick #include <sys/mman.h>
183cab2bb3Spatrick 
193cab2bb3Spatrick namespace __sanitizer {
203cab2bb3Spatrick 
RestrictMemoryToMaxAddress(uptr max_address)213cab2bb3Spatrick void RestrictMemoryToMaxAddress(uptr max_address) {
223cab2bb3Spatrick   uptr size_to_mmap = GetMaxUserVirtualAddress() + 1 - max_address;
233cab2bb3Spatrick   void *res = MmapFixedNoAccess(max_address, size_to_mmap, "high gap");
243cab2bb3Spatrick   CHECK(res != MAP_FAILED);
253cab2bb3Spatrick }
263cab2bb3Spatrick 
273cab2bb3Spatrick }  // namespace __sanitizer
283cab2bb3Spatrick 
29*810390e3Srobert #endif  // SANITIZER_APPLE
30