Enna1 created this revision.
Herald added a project: All.
Enna1 updated this revision to Diff 474450.
Enna1 added a comment.
Enna1 added a reviewer: fhahn.
Enna1 added a subscriber: MTC.
Enna1 published this revision for review.
Herald added subscribers: Sanitizers, cfe-commits, StephenFan.
Herald added projects: clang, Sanitizers.
update
fhahn added a comment.
Thanks! It looks like this makes the pre-commit testing happy!
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137414
Files:
clang/runtime/CMakeLists.txt
compiler-rt/lib/tysan/CMakeLists.txt
compiler-rt/lib/tysan/tysan_interceptors.cpp
Index: compiler-rt/lib/tysan/tysan_interceptors.cpp
===================================================================
--- compiler-rt/lib/tysan/tysan_interceptors.cpp
+++ compiler-rt/lib/tysan/tysan_interceptors.cpp
@@ -84,7 +84,7 @@
return res;
}
-#ifndef SANITIZER_APPLE
+#if !SANITIZER_APPLE
INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
int fd, OFF64_T offset) {
void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset);
@@ -154,35 +154,54 @@
return res;
}
-#ifndef SANITIZER_APPLE
+#if SANITIZER_INTERCEPT_MEMALIGN
INTERCEPTOR(void *, memalign, uptr alignment, uptr size) {
void *res = REAL(memalign)(alignment, size);
if (res)
tysan_set_type_unknown(res, size);
return res;
}
+#define TYSAN_MAYBE_INTERCEPT_MEMALIGN INTERCEPT_FUNCTION(memalign)
+#else
+#define TYSAN_MAYBE_INTERCEPT_MEMALIGN
+#endif // SANITIZER_INTERCEPT_MEMALIGN
+#if SANITIZER_INTERCEPT___LIBC_MEMALIGN
INTERCEPTOR(void *, __libc_memalign, uptr alignment, uptr size) {
void *res = REAL(__libc_memalign)(alignment, size);
if (res)
tysan_set_type_unknown(res, size);
return res;
}
+#define TYSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN \
+ INTERCEPT_FUNCTION(__libc_memalign)
+#else
+#define TYSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN
+#endif // SANITIZER_INTERCEPT___LIBC_MEMALIGN
+#if SANITIZER_INTERCEPT_PVALLOC
INTERCEPTOR(void *, pvalloc, uptr size) {
void *res = REAL(pvalloc)(size);
if (res)
tysan_set_type_unknown(res, size);
return res;
}
-#endif
+#define TYSAN_MAYBE_INTERCEPT_PVALLOC INTERCEPT_FUNCTION(pvalloc)
+#else
+#define TYSAN_MAYBE_INTERCEPT_PVALLOC
+#endif // SANITIZER_INTERCEPT_PVALLOC
+#if SANITIZER_INTERCEPT_ALIGNED_ALLOC
INTERCEPTOR(void *, aligned_alloc, uptr alignment, uptr size) {
void *res = REAL(aligned_alloc)(alignment, size);
if (res)
tysan_set_type_unknown(res, size);
return res;
}
+#define TYSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC INTERCEPT_FUNCTION(aligned_alloc)
+#else
+#define TYSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC
+#endif
INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) {
int res = REAL(posix_memalign)(memptr, alignment, size);
@@ -216,10 +235,10 @@
INTERCEPT_FUNCTION(free);
INTERCEPT_FUNCTION(realloc);
INTERCEPT_FUNCTION(valloc);
- INTERCEPT_FUNCTION(memalign);
- INTERCEPT_FUNCTION(__libc_memalign);
- INTERCEPT_FUNCTION(pvalloc);
- INTERCEPT_FUNCTION(aligned_alloc);
+ TYSAN_MAYBE_INTERCEPT_MEMALIGN;
+ TYSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN;
+ TYSAN_MAYBE_INTERCEPT_PVALLOC;
+ TYSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC
INTERCEPT_FUNCTION(posix_memalign);
INTERCEPT_FUNCTION(memset);
Index: compiler-rt/lib/tysan/CMakeLists.txt
===================================================================
--- compiler-rt/lib/tysan/CMakeLists.txt
+++ compiler-rt/lib/tysan/CMakeLists.txt
@@ -46,4 +46,19 @@
CFLAGS ${TYSAN_CFLAGS}
DEFS ${TYSAN_COMMON_DEFINITIONS}
PARENT_TARGET tysan)
+else()
+ foreach(arch ${TYSAN_SUPPORTED_ARCH})
+ set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS})
+ append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS)
+ add_compiler_rt_runtime(clang_rt.tysan
+ STATIC
+ ARCHS ${arch}
+ SOURCES ${TYSAN_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+ CFLAGS ${TYSAN_CFLAGS}
+ PARENT_TARGET tysan)
+ endforeach()
endif()
Index: clang/runtime/CMakeLists.txt
===================================================================
--- clang/runtime/CMakeLists.txt
+++ clang/runtime/CMakeLists.txt
@@ -119,7 +119,7 @@
COMPONENT compiler-rt)
# Add top-level targets that build specific compiler-rt runtimes.
- set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
+ set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan tysan ubsan ubsan-minimal)
foreach(runtime ${COMPILER_RT_RUNTIMES})
get_ext_project_build_command(build_runtime_cmd ${runtime})
add_custom_target(${runtime}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits