[compiler-rt] 0106370 - [compiler-rt | interceptors] Provide an intercept override knob.

Siva Chandra Reddy via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 3 21:03:58 PST 2021


Author: Siva Chandra Reddy
Date: 2021-03-03T21:03:46-08:00
New Revision: 0106370bee06219395f9530de6c1291fad7ba896

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

LOG: [compiler-rt | interceptors] Provide an intercept override knob.

This knob is useful for downstream users who want that some of their
libc functions to not be intercepted.

Reviewed By: eugenis

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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
index 9cff0ac2acf6..3c9907f1bcb8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -585,4 +585,25 @@
 #define SANITIZER_INTERCEPT_UNAME (SI_POSIX && !SI_FREEBSD)
 #define SANITIZER_INTERCEPT___XUNAME SI_FREEBSD
 
+// This macro gives a way for downstream users to override the above
+// interceptor macros irrespective of the platform they are on. They have
+// to do two things:
+// 1. Build compiler-rt with -DSANITIZER_OVERRIDE_INTERCEPTORS.
+// 2. Provide a header file named sanitizer_intercept_overriders.h in the
+//    include path for their compiler-rt build.
+// An example of an overrider for strlen interceptor that one can list in
+// sanitizer_intercept_overriders.h is as follows:
+//
+// #ifdef SANITIZER_INTERCEPT_STRLEN
+// #undef SANITIZER_INTERCEPT_STRLEN
+// #define SANITIZER_INTERCEPT_STRLEN <value of choice>
+// #endif
+//
+// This "feature" is useful for downstream users who do not want some of
+// their libc funtions to be intercepted. They can selectively disable
+// interception of those functions.
+#ifdef SANITIZER_OVERRIDE_INTERCEPTORS
+#include <sanitizer_intercept_overriders.h>
+#endif
+
 #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H


        


More information about the llvm-commits mailing list