[clang] [compiler-rt] [compiler-rt] adding safestack support for sunos platforms. (PR #95648)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 15 01:50:15 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-driver
Author: David CARLIER (devnexen)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/95648.diff
4 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Solaris.cpp (+1)
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1)
- (modified) compiler-rt/lib/safestack/safestack_platform.h (+9-1)
- (modified) compiler-rt/test/safestack/lit.cfg.py (+1-1)
``````````diff
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 bddaa37579fd7..c05bdd58519fb 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -833,7 +833,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..df2f05b84f1aa 100644
--- a/compiler-rt/lib/safestack/safestack_platform.h
+++ b/compiler-rt/lib/safestack/safestack_platform.h
@@ -25,7 +25,7 @@
#include <sys/types.h>
#include <unistd.h>
-#if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX)
+#if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_SOLARIS)
#error "Support for your platform has not been implemented"
#endif
@@ -39,6 +39,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 +77,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 +89,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
``````````
</details>
https://github.com/llvm/llvm-project/pull/95648
More information about the cfe-commits
mailing list