[compiler-rt] f4c4328 - [NFC][HWASAN] Add more pthread interceptors

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun May 7 16:25:22 PDT 2023


Author: Vitaly Buka
Date: 2023-05-07T16:23:01-07:00
New Revision: f4c43287f23273d93356e63652ae45fc92f6f677

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

LOG: [NFC][HWASAN] Add more pthread interceptors

They are empty for now. Follow up patches will introduce behaviour
changes.

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan_interceptors.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index 299cf371e32a..d5866b8b94b0 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -77,6 +77,25 @@ INTERCEPTOR(int, pthread_join, void *t, void **arg) {
   return REAL(pthread_join)(t, arg);
 }
 
+INTERCEPTOR(int, pthread_detach, void *thread) {
+  return REAL(pthread_detach)(thread);
+}
+
+INTERCEPTOR(int, pthread_exit, void *retval) {
+  return REAL(pthread_exit)(retval);
+}
+
+#    if SANITIZER_GLIBC
+INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **ret) {
+  return REAL(pthread_tryjoin_np)(thread, ret);
+}
+
+INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
+            const struct timespec *abstime) {
+  return REAL(pthread_timedjoin_np)(thread, ret, abstime);
+}
+#    endif
+
 DEFINE_REAL_PTHREAD_FUNCTIONS
 
 DEFINE_REAL(int, vfork)
@@ -271,6 +290,12 @@ void InitializeInterceptors() {
 #    endif  // __linux__
   INTERCEPT_FUNCTION(pthread_create);
   INTERCEPT_FUNCTION(pthread_join);
+  INTERCEPT_FUNCTION(pthread_detach);
+  INTERCEPT_FUNCTION(pthread_exit);
+#    if SANITIZER_GLIBC
+  INTERCEPT_FUNCTION(pthread_tryjoin_np);
+  INTERCEPT_FUNCTION(pthread_timedjoin_np);
+#    endif
 #  endif
 
   inited = 1;


        


More information about the llvm-commits mailing list