[llvm-branch-commits] [compiler-rt] 9875ee8 - Revert "[safestack] Various Solaris fixes (#98469)"

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jul 11 13:29:38 PDT 2024


Author: Vitaly Buka
Date: 2024-07-11T13:29:35-07:00
New Revision: 9875ee88f0f4dfe87aa1f89df00115ac796ef561

URL: https://github.com/llvm/llvm-project/commit/9875ee88f0f4dfe87aa1f89df00115ac796ef561
DIFF: https://github.com/llvm/llvm-project/commit/9875ee88f0f4dfe87aa1f89df00115ac796ef561.diff

LOG: Revert "[safestack] Various Solaris fixes (#98469)"

This reverts commit 5c205b6f7d82ee88ee5a869d6102c5a6388fb3f0.

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
    compiler-rt/lib/safestack/CMakeLists.txt
    compiler-rt/lib/safestack/safestack.cpp
    compiler-rt/lib/safestack/safestack_platform.h
    compiler-rt/test/safestack/lit.cfg.py

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 02ff92f693810..c8bec41db36e9 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
     ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
     ${LOONGARCH64})
 set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64}
-    ${HEXAGON} ${LOONGARCH64} ${SPARC} ${SPARCV9})
+    ${HEXAGON} ${LOONGARCH64})
 set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS64}
     ${HEXAGON} ${LOONGARCH64})
 set(ALL_SCUDO_STANDALONE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}

diff  --git a/compiler-rt/lib/safestack/CMakeLists.txt b/compiler-rt/lib/safestack/CMakeLists.txt
index 730043eb87cab..316ab69ecfdbe 100644
--- a/compiler-rt/lib/safestack/CMakeLists.txt
+++ b/compiler-rt/lib/safestack/CMakeLists.txt
@@ -14,8 +14,6 @@ foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
     ARCHS ${arch}
     SOURCES ${SAFESTACK_SOURCES}
             $<TARGET_OBJECTS:RTInterception.${arch}>
-    OBJECT_LIBS RTSanitizerCommon
-                RTSanitizerCommonLibc
     CFLAGS ${SAFESTACK_CFLAGS}
     PARENT_TARGET safestack)
 endforeach()

diff  --git a/compiler-rt/lib/safestack/safestack.cpp b/compiler-rt/lib/safestack/safestack.cpp
index f8ef224f45494..0751f3988b9c1 100644
--- a/compiler-rt/lib/safestack/safestack.cpp
+++ b/compiler-rt/lib/safestack/safestack.cpp
@@ -224,17 +224,6 @@ INTERCEPTOR(int, pthread_create, pthread_t *thread,
     pthread_attr_destroy(&tmpattr);
   }
 
-#if SANITIZER_SOLARIS
-  // Solaris pthread_attr_init initializes stacksize to 0 (the default), so
-  // hardcode the actual values as documented in pthread_create(3C).
-  if (size == 0)
-#  if defined(_LP64)
-    size = 2 * 1024 * 1024;
-#  else
-    size = 1024 * 1024;
-#  endif
-#endif
-
   SFS_CHECK(size);
   size = RoundUpTo(size, kStackAlign);
 

diff  --git a/compiler-rt/lib/safestack/safestack_platform.h b/compiler-rt/lib/safestack/safestack_platform.h
index 77eeb9cda6e15..d4b2e2ef7391c 100644
--- a/compiler-rt/lib/safestack/safestack_platform.h
+++ b/compiler-rt/lib/safestack/safestack_platform.h
@@ -17,7 +17,6 @@
 #include "sanitizer_common/sanitizer_platform.h"
 
 #include <dlfcn.h>
-#include <errno.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -69,24 +68,6 @@ static void *GetRealLibcAddress(const char *symbol) {
   SFS_CHECK(real_##func);
 #endif
 
-#if SANITIZER_SOLARIS
-#  define _REAL(func) _##func
-#  define DEFINE__REAL(ret_type, func, ...) \
-    extern "C" ret_type _REAL(func)(__VA_ARGS__)
-
-#  if !defined(_LP64) && _FILE_OFFSET_BITS == 64
-#    define _REAL64(func) _##func##64
-#  else
-#    define _REAL64(func) _REAL(func)
-#  endif
-#  define DEFINE__REAL64(ret_type, func, ...) \
-    extern "C" ret_type _REAL64(func)(__VA_ARGS__)
-
-DEFINE__REAL64(void *, mmap, void *a, size_t b, int c, int d, int e, off_t f);
-DEFINE__REAL(int, munmap, void *a, size_t b);
-DEFINE__REAL(int, mprotect, void *a, size_t b, int c);
-#endif
-
 using ThreadId = uint64_t;
 
 inline ThreadId GetTid() {
@@ -110,10 +91,11 @@ inline int TgKill(pid_t pid, ThreadId tid, int sig) {
   (void)pid;
   return _REAL(_lwp_kill, tid, sig);
 #elif SANITIZER_SOLARIS
-  (void)pid;
-  errno = thr_kill(tid, sig);
-  // TgKill is expected to return -1 on error, not an errno.
-  return errno != 0 ? -1 : 0;
+#  ifdef SYS_lwp_kill
+  return syscall(SYS_lwp_kill, tid, sig);
+#  else
+  return -1;
+#  endif
 #elif SANITIZER_FREEBSD
   return syscall(SYS_thr_kill2, pid, tid, sig);
 #else
@@ -128,7 +110,8 @@ inline void *Mmap(void *addr, size_t length, int prot, int flags, int fd,
 #elif SANITIZER_FREEBSD && (defined(__aarch64__) || defined(__x86_64__))
   return (void *)__syscall(SYS_mmap, addr, length, prot, flags, fd, offset);
 #elif SANITIZER_SOLARIS
-  return _REAL64(mmap)(addr, length, prot, flags, fd, offset);
+  return (void *)(uintptr_t)syscall(SYS_mmap, addr, length, prot, flags, fd,
+                                    offset);
 #else
   return (void *)syscall(SYS_mmap, addr, length, prot, flags, fd, offset);
 #endif
@@ -138,8 +121,6 @@ inline int Munmap(void *addr, size_t length) {
 #if SANITIZER_NETBSD
   DEFINE__REAL(int, munmap, void *a, size_t b);
   return _REAL(munmap, addr, length);
-#elif SANITIZER_SOLARIS
-  return _REAL(munmap)(addr, length);
 #else
   return syscall(SYS_munmap, addr, length);
 #endif
@@ -149,8 +130,6 @@ inline int Mprotect(void *addr, size_t length, int prot) {
 #if SANITIZER_NETBSD
   DEFINE__REAL(int, mprotect, void *a, size_t b, int c);
   return _REAL(mprotect, addr, length, prot);
-#elif SANITIZER_SOLARIS
-  return _REAL(mprotect)(addr, length, prot);
 #else
   return syscall(SYS_mprotect, addr, length, prot);
 #endif

diff  --git a/compiler-rt/test/safestack/lit.cfg.py b/compiler-rt/test/safestack/lit.cfg.py
index 17dfae46a412b..aadb8bf0d5c77 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", "SunOS"]:
+if config.host_os not in ["Linux", "FreeBSD", "NetBSD"]:
     config.unsupported = True


        


More information about the llvm-branch-commits mailing list