From 9f943b2446f2d0a345bbf9b4be3d3a4316372270 Mon Sep 17 00:00:00 2001 From: Hans-Peter Nilsson Date: Thu, 26 Apr 2018 01:12:56 +0000 Subject: [PATCH] As mentioned in the bogus adjustment to 160 from 144 (which is reverted here)... As mentioned in the bogus adjustment to 160 from 144 (which is reverted here), is a single-token commit in upstream r301307, an attempt to correct a failed build due to an upstream change to compile the runtime with D_FILE_OFFSET_BITS=64. The correct fix is here: just use the right include. Yes, user-struct-stat64-as-stat is actually 160 for MIPS o32 and I hear user-struct-stat is also 160 for n32. There are additional fields appended for user-struct-stat! I guess for MIPS it's as bad as it gets for mixing up kernel and user struct stat. The context of the patch doesn't show that in the #else there's the correct include, the one for to get the kernel-struct-stat. If you can't compile it, IMHO the kernel headers are just too old; 3.2 is fine for example. * sanitizer_common/sanitizer_platform_limits_linux.cc: Do not take the shortcut to #include for MIPS instead of the kernel . Explain why sys/stat.h is misleading or wrong to get the kernel struct stat. * sanitizer_common/sanitizer_platform_limits_posix.h [__mips__]: Correct the value for 32-bit non-android struct_kernel_stat_sz. From-SVN: r259664 --- libsanitizer/ChangeLog | 7 +++++++ .../sanitizer_common/sanitizer_platform_limits_linux.cc | 7 +++++-- .../sanitizer_common/sanitizer_platform_limits_posix.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index acde79f62db..141291f9e83 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,5 +1,12 @@ 2018-04-26 Hans-Peter Nilsson + * sanitizer_common/sanitizer_platform_limits_linux.cc: Do not + take the shortcut to #include for MIPS instead of + the kernel . Explain why sys/stat.h is misleading + or wrong to get the kernel struct stat. + * sanitizer_common/sanitizer_platform_limits_posix.h [__mips__]: + Correct the value for 32-bit non-android struct_kernel_stat_sz. + * sanitizer_common/sanitizer_atomic_clang_other.h [_MIPS_SIM && _MIPS_SIM == _ABIO32] (lock): Add initializer for .pad member. diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc index 23a014823c4..3a906538129 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc @@ -25,9 +25,12 @@ // With old kernels (and even new kernels on powerpc) asm/stat.h uses types that // are not defined anywhere in userspace headers. Fake them. This seems to work -// fine with newer headers, too. +// fine with newer headers, too. Beware that with , struct stat +// takes the form of struct stat64 on 32-bit platforms if _FILE_OFFSET_BITS=64. +// Also, for some platforms (e.g. mips) there are additional members in the +// struct stat:s. #include -#if defined(__x86_64__) || defined(__mips__) +#if defined(__x86_64__) #include #else #define ino_t __kernel_ino_t diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h index 4d11d071776..132e5e9beea 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h @@ -86,7 +86,7 @@ namespace __sanitizer { #elif defined(__mips__) const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID ? FIRST_32_SECOND_64(104, 128) : - FIRST_32_SECOND_64(160, 216); + FIRST_32_SECOND_64(144, 216); const unsigned struct_kernel_stat64_sz = 104; #elif defined(__s390__) && !defined(__s390x__) const unsigned struct_kernel_stat_sz = 64;