[compiler-rt] [compiler-rt] madvise interception (PR #76562)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 29 03:33:11 PST 2023
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/76562
None
>From db1882e3a6306c2bbda6c225954a01d4266919e8 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Fri, 29 Dec 2023 11:32:34 +0000
Subject: [PATCH] [compiler-rt] madvise interception
---
.../sanitizer_common_interceptors.inc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index ba46707516971f..bfd72c5897e45e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -7498,10 +7498,19 @@ INTERCEPTOR(int, mprotect, void *addr, SIZE_T sz, int prot) {
MprotectMallocZones(addr, prot);
return REAL(mprotect)(addr, sz, prot);
}
+
+INTERCEPTOR(int, madvise, uptr addr, SIZE_T sz, int advice) {
+ void *ctx;
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return (int)internal_madvise(addr, sz, advice);
+ COMMON_INTERCEPTOR_ENTER(ctx, madvise, addr, sz, advice);
+ return REAL(madvise)(addr, sz, advice);
+}
#define INIT_MMAP \
COMMON_INTERCEPT_FUNCTION(mmap); \
COMMON_INTERCEPT_FUNCTION(munmap); \
- COMMON_INTERCEPT_FUNCTION(mprotect);
+ COMMON_INTERCEPT_FUNCTION(mprotect); \
+ COMMON_INTERCEPT_FUNCTION(madvise);
#else
#define INIT_MMAP
#endif
More information about the llvm-commits
mailing list