diff mbox

[committed] Cherry-pick 2 libsanitizer aarch64 changes (PR sanitizer/64435)

Message ID 20150121212459.GR1746@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 21, 2015, 9:24 p.m. UTC
Hi!

This picks my upstream fix for aarch64 compilation against glibc 2.21+
and a first step towards aarch64 sanitizer 42/47 bit address space support.

2015-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/64435
	* sanitizer_common/sanitizer_platform_limits_posix.h: Cherry pick
	upstream r226637.
	* sanitizer_common/sanitizer_platform_limits_posix.cc: Likewise.
	* sanitizer_common/sanitizer_posix.cc: Cherry pick upstream r226639.


	Jakub

Comments

Andrew Pinski Jan. 21, 2015, 9:37 p.m. UTC | #1
On Wed, Jan 21, 2015 at 1:24 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This picks my upstream fix for aarch64 compilation against glibc 2.21+
> and a first step towards aarch64 sanitizer 42/47 bit address space support.

Even though you are cherry-picking from upstream.  The comments are incorrect.
It is 39, 42 and 48 bits.

Thanks,
Andrew Pinski


>
> 2015-01-21  Jakub Jelinek  <jakub@redhat.com>
>
>         PR sanitizer/64435
>         * sanitizer_common/sanitizer_platform_limits_posix.h: Cherry pick
>         upstream r226637.
>         * sanitizer_common/sanitizer_platform_limits_posix.cc: Likewise.
>         * sanitizer_common/sanitizer_posix.cc: Cherry pick upstream r226639.
>
> --- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h     (revision 226636)
> +++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h     (revision 226637)
> @@ -169,7 +169,7 @@ namespace __sanitizer {
>      unsigned __seq;
>      u64 __unused1;
>      u64 __unused2;
> -#elif defined(__mips__)
> +#elif defined(__mips__) || defined(__aarch64__)
>      unsigned int mode;
>      unsigned short __seq;
>      unsigned short __pad1;
> --- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc    (revision 226636)
> +++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc    (revision 226637)
> @@ -1061,7 +1061,13 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
>  CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
>  CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
>  CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
> +#ifndef __GLIBC_PREREQ
> +#define __GLIBC_PREREQ(x, y) 0
> +#endif
> +#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
> +/* On aarch64 glibc 2.20 and earlier provided incorrect mode field.  */
>  CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
> +#endif
>
>  CHECK_TYPE_SIZE(shmid_ds);
>  CHECK_SIZE_AND_OFFSET(shmid_ds, shm_perm);
> --- libsanitizer/sanitizer_common/sanitizer_posix.cc    (revision 226638)
> +++ libsanitizer/sanitizer_common/sanitizer_posix.cc    (revision 226639)
> @@ -78,16 +78,15 @@ static uptr GetKernelAreaSize() {
>
>  uptr GetMaxVirtualAddress() {
>  #if SANITIZER_WORDSIZE == 64
> -# if defined(__powerpc64__)
> +# if defined(__powerpc64__) || defined(__aarch64__)
>    // On PowerPC64 we have two different address space layouts: 44- and 46-bit.
>    // We somehow need to figure out which one we are using now and choose
>    // one of 0x00000fffffffffffUL and 0x00003fffffffffffUL.
>    // Note that with 'ulimit -s unlimited' the stack is moved away from the top
>    // of the address space, so simply checking the stack address is not enough.
>    // This should (does) work for both PowerPC64 Endian modes.
> +  // Similarly, aarch64 has multiple address space layouts: 39, 42 and 47-bit.
>    return (1ULL << (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1)) - 1;
> -# elif defined(__aarch64__)
> -  return (1ULL << 39) - 1;
>  # elif defined(__mips64)
>    return (1ULL << 40) - 1;  // 0x000000ffffffffffUL;
>  # else
>
>         Jakub
diff mbox

Patch

--- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h	(revision 226636)
+++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h	(revision 226637)
@@ -169,7 +169,7 @@  namespace __sanitizer {
     unsigned __seq;
     u64 __unused1;
     u64 __unused2;
-#elif defined(__mips__)
+#elif defined(__mips__) || defined(__aarch64__)
     unsigned int mode;
     unsigned short __seq;
     unsigned short __pad1;
--- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc	(revision 226636)
+++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc	(revision 226637)
@@ -1061,7 +1061,13 @@  CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
 CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
 CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
 CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
+#ifndef __GLIBC_PREREQ
+#define __GLIBC_PREREQ(x, y) 0
+#endif
+#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
+/* On aarch64 glibc 2.20 and earlier provided incorrect mode field.  */
 CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
+#endif
 
 CHECK_TYPE_SIZE(shmid_ds);
 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_perm);
--- libsanitizer/sanitizer_common/sanitizer_posix.cc	(revision 226638)
+++ libsanitizer/sanitizer_common/sanitizer_posix.cc	(revision 226639)
@@ -78,16 +78,15 @@  static uptr GetKernelAreaSize() {
 
 uptr GetMaxVirtualAddress() {
 #if SANITIZER_WORDSIZE == 64
-# if defined(__powerpc64__)
+# if defined(__powerpc64__) || defined(__aarch64__)
   // On PowerPC64 we have two different address space layouts: 44- and 46-bit.
   // We somehow need to figure out which one we are using now and choose
   // one of 0x00000fffffffffffUL and 0x00003fffffffffffUL.
   // Note that with 'ulimit -s unlimited' the stack is moved away from the top
   // of the address space, so simply checking the stack address is not enough.
   // This should (does) work for both PowerPC64 Endian modes.
+  // Similarly, aarch64 has multiple address space layouts: 39, 42 and 47-bit.
   return (1ULL << (MostSignificantSetBitIndex(GET_CURRENT_FRAME()) + 1)) - 1;
-# elif defined(__aarch64__)
-  return (1ULL << 39) - 1;
 # elif defined(__mips64)
   return (1ULL << 40) - 1;  // 0x000000ffffffffffUL;
 # else