Skip to content

Commit 540fd42

Browse files
authored
[compiler-rt] adding safestack support for sunos platforms. (#95648)
1 parent df067e5 commit 540fd42

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

clang/lib/Driver/ToolChains/Solaris.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ SanitizerMask Solaris::getSupportedSanitizers() const {
341341
Res |= SanitizerKind::PointerCompare;
342342
Res |= SanitizerKind::PointerSubtract;
343343
}
344+
Res |= SanitizerKind::SafeStack;
344345
Res |= SanitizerKind::Vptr;
345346
return Res;
346347
}

compiler-rt/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ else()
837837
endif()
838838

839839
if (COMPILER_RT_HAS_SANITIZER_COMMON AND SAFESTACK_SUPPORTED_ARCH AND
840-
OS_NAME MATCHES "Linux|FreeBSD|NetBSD")
840+
OS_NAME MATCHES "Linux|FreeBSD|NetBSD|SunOS")
841841
set(COMPILER_RT_HAS_SAFESTACK TRUE)
842842
else()
843843
set(COMPILER_RT_HAS_SAFESTACK FALSE)

compiler-rt/lib/safestack/safestack_platform.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#include <sys/types.h>
2626
#include <unistd.h>
2727

28-
#if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX)
29-
#error "Support for your platform has not been implemented"
28+
#if !(SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX || \
29+
SANITIZER_SOLARIS)
30+
# error "Support for your platform has not been implemented"
3031
#endif
3132

3233
#if SANITIZER_NETBSD
@@ -39,6 +40,10 @@ extern "C" void *__mmap(void *, size_t, int, int, int, int, off_t);
3940
#include <sys/thr.h>
4041
#endif
4142

43+
#if SANITIZER_SOLARIS
44+
# include <thread.h>
45+
#endif
46+
4247
namespace safestack {
4348

4449
#if SANITIZER_NETBSD
@@ -73,6 +78,8 @@ inline ThreadId GetTid() {
7378
long Tid;
7479
thr_self(&Tid);
7580
return Tid;
81+
#elif SANITIZER_SOLARIS
82+
return thr_self();
7683
#else
7784
return syscall(SYS_gettid);
7885
#endif
@@ -83,6 +90,8 @@ inline int TgKill(pid_t pid, ThreadId tid, int sig) {
8390
DEFINE__REAL(int, _lwp_kill, int a, int b);
8491
(void)pid;
8592
return _REAL(_lwp_kill, tid, sig);
93+
#elif SANITIZER_SOLARIS
94+
return syscall(SYS_lwp_kill, tid, sig);
8695
#elif SANITIZER_FREEBSD
8796
return syscall(SYS_thr_kill2, pid, tid, sig);
8897
#else

compiler-rt/test/safestack/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
)
3434
)
3535

36-
if config.host_os not in ["Linux", "FreeBSD", "NetBSD"]:
36+
if config.host_os not in ["Linux", "FreeBSD", "NetBSD", "SunOS"]:
3737
config.unsupported = True

0 commit comments

Comments
 (0)