commit 753ba67bb129ccf7f65fb2118d88c7ee7addae3b Author: Mark Johnston Date: Tue Mar 9 17:07:24 2021 -0500 llvm: Enable KASAN and KMSAN diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp index 6d8e25470e28..0948fae96ab2 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -477,8 +477,11 @@ SanitizerMask FreeBSD::getSupportedSanitizers() const { Res |= SanitizerKind::Fuzzer; Res |= SanitizerKind::FuzzerNoLink; } - if (IsX86_64) + if (IsX86_64) { + Res |= SanitizerKind::KernelAddress; + Res |= SanitizerKind::KernelMemory; Res |= SanitizerKind::Memory; + } return Res; } diff --git a/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 1557fad4d372..5ce21cc3616a 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -107,6 +107,7 @@ static const uint64_t kMIPS64_ShadowOffset64 = 1ULL << 37; static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36; static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30; static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46; +static const uint64_t kFreeBSDKasan_ShadowOffset64 = 0xdffff7c000000000; static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30; static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff900000000000; @@ -489,9 +490,12 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize, Mapping.Offset = kPPC64_ShadowOffset64; else if (IsSystemZ) Mapping.Offset = kSystemZ_ShadowOffset64; - else if (IsFreeBSD && !IsMIPS64) - Mapping.Offset = kFreeBSD_ShadowOffset64; - else if (IsNetBSD) { + else if (IsFreeBSD && !IsMIPS64) { + if (IsKasan) + Mapping.Offset = kFreeBSDKasan_ShadowOffset64; + else + Mapping.Offset = kFreeBSD_ShadowOffset64; + } else if (IsNetBSD) { if (IsKasan) Mapping.Offset = kNetBSDKasan_ShadowOffset64; else diff --git a/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index fcf7f470b3e1..3c2487a9305f 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -511,7 +511,7 @@ class MemorySanitizer { void createKernelApi(Module &M); void createUserspaceApi(Module &M); - /// True if we're compiling the Linux kernel. + /// True if we're compiling a Linux or BSD kernel. bool CompileKernel; /// Track origins (allocation points) of uninitialized values. int TrackOrigins;