[llvm-commits] [compiler-rt] r170112 - in /compiler-rt/trunk/lib: asan/asan_intercepted_functions.h asan/tests/asan_test.cc sanitizer_common/sanitizer_common_interceptors.h
Alexey Samsonov
samsonov at google.com
Thu Dec 13 00:10:23 PST 2012
Author: samsonov
Date: Thu Dec 13 02:10:23 2012
New Revision: 170112
URL: http://llvm.org/viewvc/llvm-project?rev=170112&view=rev
Log:
[ASan] more macro for conditional interception of pread functions
Modified:
compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
compiler-rt/trunk/lib/asan/tests/asan_test.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h
Modified: compiler-rt/trunk/lib/asan/asan_intercepted_functions.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_intercepted_functions.h?rev=170112&r1=170111&r2=170112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_intercepted_functions.h (original)
+++ compiler-rt/trunk/lib/asan/asan_intercepted_functions.h Thu Dec 13 02:10:23 2012
@@ -153,11 +153,16 @@
DECLARE_FUNCTION_AND_WRAPPER(long long, strtoll, const char *nptr, char **endptr, int base); // NOLINT
# endif
+// unistd.h
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, read, int fd, void *buf, SIZE_T count);
+# if SANITIZER_INTERCEPT_PREAD
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, pread, int fd, void *buf,
SIZE_T count, OFF_T offset);
+# endif
+# if SANITIZER_INTERCEPT_PREAD64
DECLARE_FUNCTION_AND_WRAPPER(SSIZE_T, pread64, int fd, void *buf,
SIZE_T count, OFF64_T offset);
+# endif
# if ASAN_INTERCEPT_MLOCKX
// mlock/munlock
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=170112&r1=170111&r2=170112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Thu Dec 13 02:10:23 2012
@@ -1606,7 +1606,7 @@
delete x;
}
-#ifndef ANDROID
+# if !defined(ANDROID) && !defined(__ANDROID__)
TEST(AddressSanitizer, pread64) {
char *x = new char[10];
int fd = open("/proc/self/stat", O_RDONLY);
@@ -1618,7 +1618,7 @@
close(fd);
delete x;
}
-#endif // ANDROID
+# endif // !defined(ANDROID) && !defined(__ANDROID__)
TEST(AddressSanitizer, read) {
char *x = new char[10];
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h?rev=170112&r1=170111&r2=170112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.h Thu Dec 13 02:10:23 2012
@@ -22,6 +22,12 @@
#include "interception/interception.h"
+#if !defined(_WIN32)
+# define SANITIZER_INTERCEPT_PREAD 1
+#else
+# define SANITIZER_INTERCEPT_PREAD 0
+#endif
+
#if defined(__linux__) && !defined(ANDROID)
# define SANITIZER_INTERCEPT_PREAD64 1
#else
@@ -36,6 +42,7 @@
return res;
}
+#if SANITIZER_INTERCEPT_PREAD
INTERCEPTOR(SSIZE_T, pread, int fd, void *ptr, SIZE_T count, OFF_T offset) {
COMMON_INTERCEPTOR_ENTER(pread, fd, ptr, count, offset);
SSIZE_T res = REAL(pread)(fd, ptr, count, offset);
@@ -43,6 +50,7 @@
COMMON_INTERCEPTOR_WRITE_RANGE(ptr, res);
return res;
}
+#endif
#if SANITIZER_INTERCEPT_PREAD64
INTERCEPTOR(SSIZE_T, pread64, int fd, void *ptr, SIZE_T count, OFF64_T offset) {
@@ -54,15 +62,21 @@
}
#endif
+#if SANITIZER_INTERCEPT_PREAD
+# define INIT_PREAD CHECK(INTERCEPT_FUNCTION(pread))
+#else
+# define INIT_PREAD
+#endif
+
#if SANITIZER_INTERCEPT_PREAD64
-#define INIT_PREAD64 CHECK(INTERCEPT_FUNCTION(pread64))
+# define INIT_PREAD64 CHECK(INTERCEPT_FUNCTION(pread64))
#else
-#define INIT_PREAD64
+# define INIT_PREAD64
#endif
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
CHECK(INTERCEPT_FUNCTION(read)); \
- CHECK(INTERCEPT_FUNCTION(pread)); \
+ INIT_PREAD; \
INIT_PREAD64; \
#endif // SANITIZER_COMMON_INTERCEPTORS_H
More information about the llvm-commits
mailing list