]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR sanitizer/85835 (libsanitizer includes <sys/ustat.h> unconditionally)
authorMatthias Klose <doko@ubuntu.com>
Fri, 21 Sep 2018 07:18:26 +0000 (07:18 +0000)
committerMatthias Klose <doko@gcc.gnu.org>
Fri, 21 Sep 2018 07:18:26 +0000 (07:18 +0000)
2017-09-21  Matthias Klose  <doko@ubuntu.com>

        Backported from the gcc-7-branch:
        2018-05-24  H.J. Lu  <hongjiu.lu@intel.com>

        PR sanitizer/85835
        * sanitizer_common/sanitizer_platform_limits_posix.cc: Don't
        include <sys/ustat.h> for Linux.
        (SIZEOF_STRUCT_USTAT): New.
        (struct_ustat_sz): Use SIZEOF_STRUCT_USTAT for Linux.

From-SVN: r264457

libsanitizer/ChangeLog
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc

index d988b28cbb1ad7c40b1f478a276d937dfc796084..2c88691ebed0998caf2318efd19de1e44bf283d4 100644 (file)
@@ -1,3 +1,14 @@
+2017-09-21  Matthias Klose  <doko@ubuntu.com>
+
+       Backported from the gcc-7-branch:
+       2018-05-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR sanitizer/85835
+       * sanitizer_common/sanitizer_platform_limits_posix.cc: Don't
+       include <sys/ustat.h> for Linux.
+       (SIZEOF_STRUCT_USTAT): New.
+       (struct_ustat_sz): Use SIZEOF_STRUCT_USTAT for Linux.
+
 2017-09-07  Matthias Klose  <doko@ubuntu.com>
 
        Backported from mainline
index 6992f2cd8ac56bcd5102f7440d71137b4458871d..98825b584d24912df76f9982c2319419c7815bf8 100644 (file)
@@ -150,7 +150,6 @@ typedef struct user_fpregs elf_fpregset_t;
 # include <sys/procfs.h>
 #endif
 #include <sys/user.h>
-#include <sys/ustat.h>
 #include <linux/cyclades.h>
 #include <linux/if_eql.h>
 #include <linux/if_plip.h>
@@ -243,7 +242,19 @@ namespace __sanitizer {
 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
-  unsigned struct_ustat_sz = sizeof(struct ustat);
+  // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
+  // has been removed from glibc 2.28.
+#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
+  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
+  || defined(__x86_64__)
+#define SIZEOF_STRUCT_USTAT 32
+#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
+  || defined(__powerpc__) || defined(__s390__)
+#define SIZEOF_STRUCT_USTAT 20
+#else
+#error Unknown size of struct ustat
+#endif
+  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID