Author: David CARLIER Date: 2024-06-29T18:13:44+01:00 New Revision: 540fd42c755f20f7b79c6c79493ec36d8cb9b3d3
URL: https://github.com/llvm/llvm-project/commit/540fd42c755f20f7b79c6c79493ec36d8cb9b3d3 DIFF: https://github.com/llvm/llvm-project/commit/540fd42c755f20f7b79c6c79493ec36d8cb9b3d3.diff LOG: [compiler-rt] adding safestack support for sunos platforms. (#95648) Added: Modified: clang/lib/Driver/ToolChains/Solaris.cpp compiler-rt/cmake/config-ix.cmake compiler-rt/lib/safestack/safestack_platform.h compiler-rt/test/safestack/lit.cfg.py Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp index 7126e018ca5b6..e82ed2ca79ffd 100644 --- a/clang/lib/Driver/ToolChains/Solaris.cpp +++ b/clang/lib/Driver/ToolChains/Solaris.cpp @@ -341,6 +341,7 @@ SanitizerMask Solaris::getSupportedSanitizers() const { Res |= SanitizerKind::PointerCompare; Res |= SanitizerKind::PointerSubtract; } + Res |= SanitizerKind::SafeStack; Res |= SanitizerKind::Vptr; return Res; } diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 75e4d3677703a..7037bf89d6532 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -837,7 +837,7 @@ else() endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND SAFESTACK_SUPPORTED_ARCH AND - OS_NAME MATCHES "Linux|FreeBSD|NetBSD") + OS_NAME MATCHES "Linux|FreeBSD|NetBSD|SunOS") set(COMPILER_RT_HAS_SAFESTACK TRUE) else() set(COMPILER_RT_HAS_SAFESTACK FALSE) diff --git a/compiler-rt/lib/safestack/safestack_platform.h b/compiler-rt/lib/safestack/safestack_platform.h index 2b1fc139baa90..822611315d010 100644 --- a/compiler-rt/lib/safestack/safestack_platform.h +++ b/compiler-rt/lib/safestack/safestack_platform.h @@ -25,8 +25,9 @@ #include <sys/types.h> #include <unistd.h> -#if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX) -#error "Support for your platform has not been implemented" +#if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX || \ + SANITIZER_SOLARIS) +# error "Support for your platform has not been implemented" #endif #if SANITIZER_NETBSD @@ -39,6 +40,10 @@ extern "C" void *__mmap(void *, size_t, int, int, int, int, off_t); #include <sys/thr.h> #endif +#if SANITIZER_SOLARIS +# include <thread.h> +#endif + namespace safestack { #if SANITIZER_NETBSD @@ -73,6 +78,8 @@ inline ThreadId GetTid() { long Tid; thr_self(&Tid); return Tid; +#elif SANITIZER_SOLARIS + return thr_self(); #else return syscall(SYS_gettid); #endif @@ -83,6 +90,8 @@ inline int TgKill(pid_t pid, ThreadId tid, int sig) { DEFINE__REAL(int, _lwp_kill, int a, int b); (void)pid; return _REAL(_lwp_kill, tid, sig); +#elif SANITIZER_SOLARIS + return syscall(SYS_lwp_kill, tid, sig); #elif SANITIZER_FREEBSD return syscall(SYS_thr_kill2, pid, tid, sig); #else diff --git a/compiler-rt/test/safestack/lit.cfg.py b/compiler-rt/test/safestack/lit.cfg.py index aadb8bf0d5c77..17dfae46a412b 100644 --- a/compiler-rt/test/safestack/lit.cfg.py +++ b/compiler-rt/test/safestack/lit.cfg.py @@ -33,5 +33,5 @@ ) ) -if config.host_os not in ["Linux", "FreeBSD", "NetBSD"]: +if config.host_os not in ["Linux", "FreeBSD", "NetBSD", "SunOS"]: config.unsupported = True _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits