From 5e1c9963cb8a2244fbe31d5e8594b757051ef3eb Mon Sep 17 00:00:00 2001 From: gnezdo Date: Wed, 16 Feb 2022 03:48:55 +0000 Subject: [PATCH] Add ifdefs to build ubsan_minimal on OpenBSD ok jca@ --- gnu/llvm/compiler-rt/lib/interception/interception.h | 4 ++-- .../compiler-rt/lib/interception/interception_linux.h | 2 +- .../compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | 2 +- .../compiler-rt/lib/sanitizer_common/sanitizer_linux.h | 2 +- .../lib/sanitizer_common/sanitizer_platform.h | 9 ++++++++- gnu/llvm/compiler-rt/lib/ubsan/ubsan_platform.h | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gnu/llvm/compiler-rt/lib/interception/interception.h b/gnu/llvm/compiler-rt/lib/interception/interception.h index d8dc092c45f..fb91a4cc32b 100644 --- a/gnu/llvm/compiler-rt/lib/interception/interception.h +++ b/gnu/llvm/compiler-rt/lib/interception/interception.h @@ -18,7 +18,7 @@ #if !SANITIZER_LINUX && !SANITIZER_FREEBSD && !SANITIZER_MAC && \ !SANITIZER_NETBSD && !SANITIZER_WINDOWS && !SANITIZER_FUCHSIA && \ - !SANITIZER_SOLARIS + !SANITIZER_OPENBSD && !SANITIZER_SOLARIS # error "Interception doesn't work on this operating system." #endif @@ -272,7 +272,7 @@ typedef unsigned long uptr; #define INCLUDED_FROM_INTERCEPTION_LIB #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ - SANITIZER_SOLARIS + SANITIZER_OPENBSD || SANITIZER_SOLARIS # include "interception_linux.h" # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) diff --git a/gnu/llvm/compiler-rt/lib/interception/interception_linux.h b/gnu/llvm/compiler-rt/lib/interception/interception_linux.h index a08f8cb98c4..b554b53d1dc 100644 --- a/gnu/llvm/compiler-rt/lib/interception/interception_linux.h +++ b/gnu/llvm/compiler-rt/lib/interception/interception_linux.h @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ - SANITIZER_SOLARIS + SANITIZER_OPENBSD || SANITIZER_SOLARIS #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) # error "interception_linux.h should be included from interception library only" diff --git a/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp index 9b7d87eb85e..369e5514e3f 100644 --- a/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp +++ b/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp @@ -518,7 +518,7 @@ u64 NanoTime() { // 'environ' array (on some others) and does not use libc. This function // should be called first inside __asan_init. const char *GetEnv(const char *name) { -#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_SOLARIS +#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_OPENBSD || SANITIZER_SOLARIS if (::environ != 0) { uptr NameLen = internal_strlen(name); for (char **Env = ::environ; *Env != 0; Env++) { diff --git a/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.h b/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.h index 9a23fcfb3b9..389c53113b1 100644 --- a/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.h +++ b/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux.h @@ -14,7 +14,7 @@ #include "sanitizer_platform.h" #if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \ - SANITIZER_SOLARIS + SANITIZER_OPENBSD || SANITIZER_SOLARIS #include "sanitizer_common.h" #include "sanitizer_internal_defs.h" #include "sanitizer_platform_limits_freebsd.h" diff --git a/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_platform.h index 4d3c08893c1..64dcaaded83 100644 --- a/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_platform.h +++ b/gnu/llvm/compiler-rt/lib/sanitizer_common/sanitizer_platform.h @@ -13,6 +13,7 @@ #define SANITIZER_PLATFORM_H #if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ + !defined(__OpenBSD__) && \ !defined(__APPLE__) && !defined(_WIN32) && !defined(__Fuchsia__) && \ !(defined(__sun__) && defined(__svr4__)) # error "This operating system is not supported" @@ -49,6 +50,12 @@ # define SANITIZER_NETBSD 0 #endif +#if defined(__OpenBSD__) +# define SANITIZER_OPENBSD 1 +#else +# define SANITIZER_OPENBSD 0 +#endif + #if defined(__sun__) && defined(__svr4__) # define SANITIZER_SOLARIS 1 #else @@ -118,7 +125,7 @@ #define SANITIZER_POSIX \ (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC || \ - SANITIZER_NETBSD || SANITIZER_SOLARIS) + SANITIZER_NETBSD || SANITIZER_OPENBSD || SANITIZER_SOLARIS) #if __LP64__ || defined(_WIN64) # define SANITIZER_WORDSIZE 64 diff --git a/gnu/llvm/compiler-rt/lib/ubsan/ubsan_platform.h b/gnu/llvm/compiler-rt/lib/ubsan/ubsan_platform.h index d2cc2e10bd2..51d29c066f0 100644 --- a/gnu/llvm/compiler-rt/lib/ubsan/ubsan_platform.h +++ b/gnu/llvm/compiler-rt/lib/ubsan/ubsan_platform.h @@ -14,7 +14,7 @@ // Other platforms should be easy to add, and probably work as-is. #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \ - defined(__NetBSD__) || defined(__DragonFly__) || \ + defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || \ (defined(__sun__) && defined(__svr4__)) || defined(_WIN32) || \ defined(__Fuchsia__) #define CAN_SANITIZE_UB 1 -- 2.20.1