sanitizer_mac_libcdep.cpp 972 B

1234567891011121314151617181920212223242526272829
  1. //===-- sanitizer_mac_libcdep.cpp -----------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is shared between various sanitizers' runtime libraries and
  10. // implements OSX-specific functions.
  11. //===----------------------------------------------------------------------===//
  12. #include "sanitizer_platform.h"
  13. #if SANITIZER_APPLE
  14. #include "sanitizer_mac.h"
  15. #include <sys/mman.h>
  16. namespace __sanitizer {
  17. void RestrictMemoryToMaxAddress(uptr max_address) {
  18. uptr size_to_mmap = GetMaxUserVirtualAddress() + 1 - max_address;
  19. void *res = MmapFixedNoAccess(max_address, size_to_mmap, "high gap");
  20. CHECK(res != MAP_FAILED);
  21. }
  22. } // namespace __sanitizer
  23. #endif // SANITIZER_APPLE