From 1bb2229028dd78280d24c26b9efbe8476d966e05 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Wed, 30 Oct 2013 00:58:17 +0000 Subject: [asan] Fix syscall hooks build on Android. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193670 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/sanitizer_common_syscalls.inc | 18 +++++++++++------- .../sanitizer_platform_limits_linux.cc | 7 +++++++ .../sanitizer_platform_limits_posix.cc | 5 ++++- lib/sanitizer_common/sanitizer_platform_limits_posix.h | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc index baa1d5be..00321555 100644 --- a/lib/sanitizer_common/sanitizer_common_syscalls.inc +++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc @@ -2063,6 +2063,13 @@ POST_SYSCALL(shmdt)(long res, void *shmaddr) { } } +PRE_SYSCALL(ipc)(long call, long first, long second, long third, void *ptr, + long fifth) {} + +POST_SYSCALL(ipc)(long res, long call, long first, long second, long third, + void *ptr, long fifth) {} + +#if !SANITIZER_ANDROID PRE_SYSCALL(shmctl)(long shmid, long cmd, void *buf) {} POST_SYSCALL(shmctl)(long res, long shmid, long cmd, void *buf) { @@ -2071,13 +2078,6 @@ POST_SYSCALL(shmctl)(long res, long shmid, long cmd, void *buf) { } } -PRE_SYSCALL(ipc)(long call, long first, long second, long third, void *ptr, - long fifth) {} - -POST_SYSCALL(ipc)(long res, long call, long first, long second, long third, - void *ptr, long fifth) {} - -#if !SANITIZER_ANDROID PRE_SYSCALL(mq_open)(const void *name, long oflag, long mode, void *attr) { if (name) PRE_READ(name, __sanitizer::internal_strlen((const char *)name) + 1); @@ -2219,6 +2219,7 @@ PRE_SYSCALL(ni_syscall)() {} POST_SYSCALL(ni_syscall)(long res) {} PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) { +#if defined(__i386) || defined (__x86_64) if (data) { if (request == ptrace_setregs) { PRE_READ((void *)data, struct_user_regs_struct_sz); @@ -2233,9 +2234,11 @@ PRE_SYSCALL(ptrace)(long request, long pid, long addr, long data) { PRE_READ(iov->iov_base, iov->iov_len); } } +#endif } POST_SYSCALL(ptrace)(long res, long request, long pid, long addr, long data) { +#if defined(__i386) || defined (__x86_64) if (res >= 0 && data) { // Note that this is different from the interceptor in // sanitizer_common_interceptors.inc. @@ -2256,6 +2259,7 @@ POST_SYSCALL(ptrace)(long res, long request, long pid, long addr, long data) { POST_WRITE((void *)data, sizeof(void *)); } } +#endif } PRE_SYSCALL(add_key)(const void *_type, const void *_description, diff --git a/lib/sanitizer_common/sanitizer_platform_limits_linux.cc b/lib/sanitizer_common/sanitizer_platform_limits_linux.cc index a957cbe3..9d4eb349 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_linux.cc +++ b/lib/sanitizer_common/sanitizer_platform_limits_linux.cc @@ -23,6 +23,12 @@ #include #include +#if SANITIZER_ANDROID +#include +#else +#include +#endif + #if !SANITIZER_ANDROID #include #endif @@ -32,6 +38,7 @@ namespace __sanitizer { unsigned struct_kernel_stat_sz = sizeof(struct stat); unsigned struct_io_event_sz = sizeof(struct io_event); unsigned struct_iocb_sz = sizeof(struct iocb); + unsigned struct_statfs64_sz = sizeof(struct statfs64); #ifndef _LP64 unsigned struct_kernel_stat64_sz = sizeof(struct stat64); diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc index 8276a969..133ddcf2 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -143,9 +143,12 @@ namespace __sanitizer { unsigned struct_sched_param_sz = sizeof(struct sched_param); unsigned struct_statfs_sz = sizeof(struct statfs); +#if SANITIZER_MAC + unsigned struct_statfs64_sz = sizeof(struct statfs64); +#endif + #if !SANITIZER_ANDROID unsigned ucontext_t_sz = sizeof(ucontext_t); - unsigned struct_statfs64_sz = sizeof(struct statfs64); #endif // !SANITIZER_ANDROID #if SANITIZER_LINUX diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/lib/sanitizer_common/sanitizer_platform_limits_posix.h index 6f27ba44..864162d2 100644 --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -39,10 +39,10 @@ namespace __sanitizer { extern unsigned struct_sigevent_sz; extern unsigned struct_sched_param_sz; extern unsigned struct_statfs_sz; + extern unsigned struct_statfs64_sz; #if !SANITIZER_ANDROID extern unsigned ucontext_t_sz; - extern unsigned struct_statfs64_sz; #endif // !SANITIZER_ANDROID #if SANITIZER_LINUX -- cgit v1.2.3