[compiler-rt] 1e36bd8 - [compiler-rt][darwin] check for strcmp to test interceptors instead of pthread_create

Emily Shi via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 16:17:31 PST 2022


Author: Emily Shi
Date: 2022-01-12T16:17:26-08:00
New Revision: 1e36bd8516f23e2eaf9c3c6c2005a8cf66070896

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

LOG: [compiler-rt][darwin] check for strcmp to test interceptors instead of pthread_create

If `pthread_create` is not available on a platform, we won't be able to check if interceptors work. Use `strcmp` instead.

Reviewed By: yln

Differential Revision: https://reviews.llvm.org/D116989

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index a2fc310ad1a29..b15bad7fb21b3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -1050,13 +1050,13 @@ void MaybeReexec() {
     RAW_CHECK("execv failed" && 0);
   }
 
-  // Verify that interceptors really work.  We'll use dlsym to locate
-  // "pthread_create", if interceptors are working, it should really point to
-  // "wrap_pthread_create" within our own dylib.
-  Dl_info info_pthread_create;
-  void *dlopen_addr = dlsym(RTLD_DEFAULT, "pthread_create");
-  RAW_CHECK(dladdr(dlopen_addr, &info_pthread_create));
-  if (internal_strcmp(info.dli_fname, info_pthread_create.dli_fname) != 0) {
+  // Verify that interceptors really work. We'll use dlsym to locate
+  // "strcmp", if interceptors are working, it should really point to
+  // "wrap_strcmp" within our own dylib.
+  Dl_info info_strcmp;
+  void *dlopen_addr = dlsym(RTLD_DEFAULT, "strcmp");
+  RAW_CHECK(dladdr(dlopen_addr, &info_strcmp));
+  if (internal_strcmp(info.dli_fname, info_strcmp.dli_fname) != 0) {
     Report(
         "ERROR: Interceptors are not working. This may be because %s is "
         "loaded too late (e.g. via dlopen). Please launch the executable "


        


More information about the llvm-commits mailing list