]>
Commit | Line | Data |
---|---|---|
dee5ea7a KS |
1 | //===-- sanitizer_mac.h -----------------------------------------*- C++ -*-===// |
2 | // | |
b667dd70 ML |
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 | |
dee5ea7a KS |
6 | // |
7 | //===----------------------------------------------------------------------===// | |
8 | // | |
9 | // This file is shared between various sanitizers' runtime libraries and | |
10 | // provides definitions for OSX-specific functions. | |
11 | //===----------------------------------------------------------------------===// | |
12 | #ifndef SANITIZER_MAC_H | |
13 | #define SANITIZER_MAC_H | |
14 | ||
10189819 | 15 | #include "sanitizer_common.h" |
dee5ea7a KS |
16 | #include "sanitizer_platform.h" |
17 | #if SANITIZER_MAC | |
696d846a | 18 | #include "sanitizer_posix.h" |
dee5ea7a KS |
19 | |
20 | namespace __sanitizer { | |
21 | ||
5d3805fc JJ |
22 | struct MemoryMappingLayoutData { |
23 | int current_image; | |
24 | u32 current_magic; | |
25 | u32 current_filetype; | |
26 | ModuleArch current_arch; | |
27 | u8 current_uuid[kModuleUUIDSize]; | |
28 | int current_load_cmd_count; | |
eac97531 | 29 | const char *current_load_cmd_addr; |
5d3805fc JJ |
30 | bool current_instrumented; |
31 | }; | |
32 | ||
dee5ea7a KS |
33 | enum MacosVersion { |
34 | MACOS_VERSION_UNINITIALIZED = 0, | |
35 | MACOS_VERSION_UNKNOWN, | |
3c6331c2 | 36 | MACOS_VERSION_LION, // macOS 10.7; oldest currently supported |
dee5ea7a | 37 | MACOS_VERSION_MOUNTAIN_LION, |
c5be964a KS |
38 | MACOS_VERSION_MAVERICKS, |
39 | MACOS_VERSION_YOSEMITE, | |
eac97531 ML |
40 | MACOS_VERSION_EL_CAPITAN, |
41 | MACOS_VERSION_SIERRA, | |
42 | MACOS_VERSION_HIGH_SIERRA, | |
43 | MACOS_VERSION_MOJAVE, | |
b667dd70 | 44 | MACOS_VERSION_CATALINA, |
696d846a | 45 | MACOS_VERSION_UNKNOWN_NEWER |
dee5ea7a KS |
46 | }; |
47 | ||
3c6331c2 ML |
48 | struct DarwinKernelVersion { |
49 | u16 major; | |
50 | u16 minor; | |
51 | ||
52 | DarwinKernelVersion(u16 major, u16 minor) : major(major), minor(minor) {} | |
53 | ||
54 | bool operator==(const DarwinKernelVersion &other) const { | |
55 | return major == other.major && minor == other.minor; | |
56 | } | |
57 | bool operator>=(const DarwinKernelVersion &other) const { | |
58 | return major >= other.major || | |
59 | (major == other.major && minor >= other.minor); | |
60 | } | |
61 | }; | |
62 | ||
dee5ea7a | 63 | MacosVersion GetMacosVersion(); |
3c6331c2 | 64 | DarwinKernelVersion GetDarwinKernelVersion(); |
dee5ea7a | 65 | |
696d846a MO |
66 | char **GetEnviron(); |
67 | ||
5d3805fc JJ |
68 | void RestrictMemoryToMaxAddress(uptr max_address); |
69 | ||
dee5ea7a KS |
70 | } // namespace __sanitizer |
71 | ||
10189819 MO |
72 | extern "C" { |
73 | static char __crashreporter_info_buff__[__sanitizer::kErrorMessageBufferSize] = | |
74 | {}; | |
75 | static const char *__crashreporter_info__ __attribute__((__used__)) = | |
76 | &__crashreporter_info_buff__[0]; | |
77 | asm(".desc ___crashreporter_info__, 0x10"); | |
78 | } // extern "C" | |
79 | ||
80 | namespace __sanitizer { | |
81 | static BlockingMutex crashreporter_info_mutex(LINKER_INITIALIZED); | |
82 | ||
83 | INLINE void CRAppendCrashLogMessage(const char *msg) { | |
84 | BlockingMutexLock l(&crashreporter_info_mutex); | |
85 | internal_strlcat(__crashreporter_info_buff__, msg, | |
86 | sizeof(__crashreporter_info_buff__)); } | |
87 | } // namespace __sanitizer | |
88 | ||
dee5ea7a KS |
89 | #endif // SANITIZER_MAC |
90 | #endif // SANITIZER_MAC_H |