From: Vitaly Buka Date: Fri, 23 Mar 2018 21:44:59 +0000 (+0000) Subject: FreeBSD sanitizer common, intercept couple of more functions X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b53180846b7cd2489b1f99271010214de0dc4533;p=platform%2Fupstream%2Fllvm.git FreeBSD sanitizer common, intercept couple of more functions Summary: Intercepts lstat, acct, access, faccessat and strlcpy/strlcat Patch by David CARLIER Reviewers: visa, vitalybuka Subscribers: krytarowski, fedor.sergeev, srhines, kubamracek, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D44432 llvm-svn: 328376 --- diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h index c751f3c..56102c90 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -432,7 +432,7 @@ #define SANITIZER_INTERCEPT_STAT \ (SI_FREEBSD || SI_MAC || SI_ANDROID || SI_NETBSD || SI_OPENBSD || SI_SOLARIS) -#define SANITIZER_INTERCEPT_LSTAT SI_NETBSD +#define SANITIZER_INTERCEPT_LSTAT (SI_NETBSD || SI_FREEBSD) #define SANITIZER_INTERCEPT___XSTAT (!SANITIZER_INTERCEPT_STAT && SI_POSIX) #define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT @@ -463,16 +463,16 @@ #define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION (!SI_WINDOWS && SI_NOT_FUCHSIA) #define SANITIZER_INTERCEPT_BSD_SIGNAL SI_ANDROID -#define SANITIZER_INTERCEPT_ACCT (SI_NETBSD || SI_OPENBSD) +#define SANITIZER_INTERCEPT_ACCT (SI_NETBSD || SI_OPENBSD || SI_FREEBSD) #define SANITIZER_INTERCEPT_USER_FROM_UID SI_NETBSD #define SANITIZER_INTERCEPT_UID_FROM_USER SI_NETBSD #define SANITIZER_INTERCEPT_GROUP_FROM_GID SI_NETBSD #define SANITIZER_INTERCEPT_GID_FROM_GROUP SI_NETBSD -#define SANITIZER_INTERCEPT_ACCESS (SI_NETBSD || SI_OPENBSD) -#define SANITIZER_INTERCEPT_FACCESSAT (SI_NETBSD || SI_OPENBSD) +#define SANITIZER_INTERCEPT_ACCESS (SI_NETBSD || SI_OPENBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_FACCESSAT (SI_NETBSD || SI_OPENBSD || SI_FREEBSD) #define SANITIZER_INTERCEPT_GETGROUPLIST (SI_NETBSD || SI_OPENBSD) -#define SANITIZER_INTERCEPT_GETGROUPMEMBERSHIP SI_NETBSD -#define SANITIZER_INTERCEPT_STRLCPY (SI_NETBSD || SI_OPENBSD) +#define SANITIZER_INTERCEPT_STRLCPY \ + (SI_NETBSD || SI_FREEBSD || SI_OPENBSD || SI_MAC || SI_ANDROID) #define SANITIZER_INTERCEPT_NAME_TO_HANDLE_AT SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT_OPEN_BY_HANDLE_AT SI_LINUX_NOT_ANDROID @@ -487,10 +487,10 @@ #define SANITIZER_INTERCEPT_READLINKAT \ (SI_POSIX && !SI_MAC_DEPLOYMENT_BELOW_10_10) -#define SANITIZER_INTERCEPT_DEVNAME (SI_NETBSD || SI_OPENBSD) -#define SANITIZER_INTERCEPT_DEVNAME_R SI_NETBSD -#define SANITIZER_INTERCEPT_FGETLN SI_NETBSD -#define SANITIZER_INTERCEPT_STRMODE SI_NETBSD +#define SANITIZER_INTERCEPT_DEVNAME (SI_NETBSD || SI_OPENBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_DEVNAME_R (SI_NETBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_FGETLN (SI_NETBSD || SI_FREEBSD) +#define SANITIZER_INTERCEPT_STRMODE (SI_NETBSD || SI_FREEBSD) #define SANITIZER_INTERCEPT_TTYENT SI_NETBSD #define SANITIZER_INTERCEPT_PROTOENT SI_NETBSD #define SANITIZER_INTERCEPT_NETENT SI_NETBSD diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/access.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/access.cc similarity index 100% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/access.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/access.cc diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/devname.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/devname.cc similarity index 92% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/devname.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/devname.cc index 8cde9eb..da4bb88 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/devname.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/devname.cc @@ -1,4 +1,5 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s +// UNSUPPORTED: linux, solaris #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/devname_r.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/devname_r.cc similarity index 81% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/devname_r.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/devname_r.cc index ef65dfd..f7925f5 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/devname_r.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/devname_r.cc @@ -1,4 +1,5 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s +// UNSUPPORTED: linux, solaris #include #include @@ -16,7 +17,7 @@ int main(void) { type = S_ISCHR(st.st_mode) ? S_IFCHR : S_IFBLK; - if (devname_r(st.st_rdev, type, name, __arraycount(name))) + if (devname_r(st.st_rdev, type, name, sizeof(name))) exit(1); printf("%s\n", name); diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/fgetln.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cc similarity index 93% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/fgetln.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cc index 2c4f83d..e98cf44 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/fgetln.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cc @@ -1,4 +1,5 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t +// UNSUPPORTED: linux #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cc index b91a3d7..bf198ef 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cc @@ -5,13 +5,19 @@ #include #include -#include #include #if __linux__ #include +#elif defined(__FreeBSD__) +#include +#include +#include +#include +#include #else #include #endif +#include int main (int argc, char** argv) diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/lstat.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cc similarity index 100% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/lstat.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/lstat.cc diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strlcat.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/strlcat.cc similarity index 97% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/strlcat.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/strlcat.cc index ea50458..bdabada 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strlcat.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/strlcat.cc @@ -1,5 +1,7 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t +// UNSUPPORTED: linux + #include #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strlcpy.cc b/compiler-rt/test/sanitizer_common/TestCases/Posix/strlcpy.cc similarity index 97% rename from compiler-rt/test/sanitizer_common/TestCases/NetBSD/strlcpy.cc rename to compiler-rt/test/sanitizer_common/TestCases/Posix/strlcpy.cc index 9963486..8305391 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/NetBSD/strlcpy.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/strlcpy.cc @@ -1,5 +1,7 @@ // RUN: %clangxx -O0 -g %s -o %t && %run %t +// UNSUPPORTED: linux + #include #include #include diff --git a/compiler-rt/test/sanitizer_common/lit.common.cfg b/compiler-rt/test/sanitizer_common/lit.common.cfg index 72e3e5e..0e9183b 100644 --- a/compiler-rt/test/sanitizer_common/lit.common.cfg +++ b/compiler-rt/test/sanitizer_common/lit.common.cfg @@ -59,5 +59,5 @@ config.substitutions.append( ('%env_tool_opts=', config.suffixes = ['.c', '.cc', '.cpp'] -if config.host_os not in ['Linux', 'Darwin', 'NetBSD']: +if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']: config.unsupported = True