Skip to content

Commit

Permalink
[compiler-rt] adding safestack support for sunos platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jun 15, 2024
1 parent 8cc6a24 commit 33f68c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Solaris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ SanitizerMask Solaris::getSupportedSanitizers() const {
Res |= SanitizerKind::PointerCompare;
Res |= SanitizerKind::PointerSubtract;
}
Res |= SanitizerKind::SafeStack;
Res |= SanitizerKind::Vptr;
return Res;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion compiler-rt/lib/safestack/safestack_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/safestack/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 33f68c3

Please sign in to comment.