[compiler-rt] r199192 - [asan] Include <sys/stat.h> if __x86_64__ is defined

Kostya Serebryany kcc at google.com
Mon Jan 13 23:38:54 PST 2014


Author: kcc
Date: Tue Jan 14 01:38:53 2014
New Revision: 199192

URL: http://llvm.org/viewvc/llvm-project?rev=199192&view=rev
Log:
[asan] Include <sys/stat.h> if __x86_64__ is defined

struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
isn't used for x86-64 nor x32.  This patch includes <sys/stat.h> instead
of <asm/stat.h> and comments out size check of struct __old_kernel_stat
for x86-64.

Patch by H.J. Lu


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc?rev=199192&r1=199191&r2=199192&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_linux.cc Tue Jan 14 01:38:53 2014
@@ -29,6 +29,9 @@
 // are not defined anywhere in userspace headers. Fake them. This seems to work
 // fine with newer headers, too.
 #include <asm/posix_types.h>
+#if defined(__x86_64__)
+#include <sys/stat.h>
+#else
 #define ino_t __kernel_ino_t
 #define mode_t __kernel_mode_t
 #define nlink_t __kernel_nlink_t
@@ -43,6 +46,7 @@
 #undef uid_t
 #undef gid_t
 #undef off_t
+#endif
 
 #include <linux/aio_abi.h>
 
@@ -60,7 +64,7 @@ namespace __sanitizer {
   unsigned struct_statfs64_sz = sizeof(struct statfs64);
 }  // namespace __sanitizer
 
-#if !defined(__powerpc64__)
+#if !defined(__powerpc64__) && !defined(__x86_64__)
 COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
 #endif
 

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=199192&r1=199191&r2=199192&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h Tue Jan 14 01:38:53 2014
@@ -169,6 +169,11 @@ namespace __sanitizer {
   #elif !defined(__powerpc64__)
     uptr __unused0;
   #endif
+  #if defined(__x86_64__) && !defined(_LP64)
+    u64 shm_atime;
+    u64 shm_dtime;
+    u64 shm_ctime;
+  #else
     uptr shm_atime;
   #ifndef _LP64
     uptr __unused1;
@@ -181,14 +186,21 @@ namespace __sanitizer {
   #ifndef _LP64
     uptr __unused3;
   #endif
+  #endif
   #ifdef __powerpc__
     uptr shm_segsz;
   #endif
     int shm_cpid;
     int shm_lpid;
+  #if defined(__x86_64__) && !defined(_LP64)
+    u64 shm_nattch;
+    u64 __unused4;
+    u64 __unused5;
+  #else
     uptr shm_nattch;
     uptr __unused4;
     uptr __unused5;
+  #endif
   };
   #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
 
@@ -296,7 +308,11 @@ namespace __sanitizer {
   };
 #endif
 
+#if defined(__x86_64__) && !defined(_LP64)
+  typedef long long __sanitizer_clock_t;
+#else
   typedef long __sanitizer_clock_t;
+#endif
 
 #if SANITIZER_LINUX
 #if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__)





More information about the llvm-commits mailing list