summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Golin <renato.golin@linaro.org>2015-02-24 11:38:41 +0000
committerRenato Golin <renato.golin@linaro.org>2015-02-24 11:38:41 +0000
commit9b1e758a552ce61cc4d8f8cc0f62222e1868be2e (patch)
tree841b688380834f9ce9c40400d1f0664d3ebe0c58
parent90c8b0e0928bbcc7afd12a9fd8f9eece67c9430c (diff)
downloadbcm5719-llvm-9b1e758a552ce61cc4d8f8cc0f62222e1868be2e.tar.gz
bcm5719-llvm-9b1e758a552ce61cc4d8f8cc0f62222e1868be2e.zip
Allow sanitizer to work with "old" kernel headers
Sanitizers work on ancient kernels and were depending on types existing. When those types were removed, the sanitizer build broke. See bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59009 for more information. This patch fixes it by isolating the need for those types only when the feature is actually needed, thus allowing one to compile the kernel with or without that change, irrespective of its version. Patch by Christophe Lyon. llvm-svn: 230324
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc2
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_platform.h13
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc2
3 files changed, 16 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
index 7e15d51ff35..f2c054e2e96 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
@@ -1443,6 +1443,7 @@ PRE_SYSCALL(fchown)(long fd, long user, long group) {}
POST_SYSCALL(fchown)(long res, long fd, long user, long group) {}
+#if SANITIZER_USES_UID16_SYSCALLS
PRE_SYSCALL(chown16)(const void *filename, long user, long group) {
if (filename)
PRE_READ(filename,
@@ -1552,6 +1553,7 @@ POST_SYSCALL(getgid16)(long res) {}
PRE_SYSCALL(getegid16)() {}
POST_SYSCALL(getegid16)(long res) {}
+#endif // SANITIZER_USES_UID16_SYSCALLS
PRE_SYSCALL(utime)(void *filename, void *times) {}
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 6f8cd30bf4d..fef5a5bcdf9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -111,6 +111,19 @@
# endif
#endif
+// udi16 syscalls can only be used when the following conditions are
+// met:
+// * target is one of arm32, x86-32, sparc32, sh or m68k
+// * libc version is libc5, glibc-2.0, glibc-2.1 or glibc-2.2 to 2.15
+// built against > linux-2.2 kernel headers
+// Since we don't want to include libc headers here, we check the
+// target only.
+#if defined(__arm__) || SANITIZER_X32 || defined(__sparc__)
+#define SANITIZER_USES_UID16_SYSCALLS 1
+#else
+#define SANITIZER_USES_UID16_SYSCALLS 0
+#endif
+
#ifdef __mips__
# define SANITIZER_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 10)
#else
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
index 8824c8088f2..2839e92a7fc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -1016,7 +1016,7 @@ CHECK_SIZE_AND_OFFSET(__sysctl_args, newlen);
CHECK_TYPE_SIZE(__kernel_uid_t);
CHECK_TYPE_SIZE(__kernel_gid_t);
-#if !defined(__aarch64__)
+#if SANITIZER_USES_UID16_SYSCALLS
CHECK_TYPE_SIZE(__kernel_old_uid_t);
CHECK_TYPE_SIZE(__kernel_old_gid_t);
#endif
OpenPOWER on IntegriCloud