[02/61] Add shadow-map for n32 ABI

Message ID 20250131171232.1018281-4-aleksandar.rakic@htecgroup.com
State New
Headers
Series Improve Mips target |

Commit Message

Aleksandar Rakic Jan. 31, 2025, 5:13 p.m. UTC
  From: Faraz Shahbazker <fshahbazker@wavecomp.com>

libsanitizer:
        * asan/asan_mapping.h (ASAN_SHADOW_OFFSET_CONST): Set correct
        offset for n32 ABI.

Cherry-picked 12ec4fc5c3a19e6304b58775db1820892942efbc
from https://github.com/MIPS/gcc

Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com>
Signed-off-by: Chao-ying Fu <cfu@mips.com>
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
---
 libsanitizer/asan/asan_mapping.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
  

Comments

Richard Biener Feb. 3, 2025, 9:33 a.m. UTC | #1
On Fri, Jan 31, 2025 at 6:31 PM Aleksandar Rakic
<aleksandar.rakic@htecgroup.com> wrote:
>
> From: Faraz Shahbazker <fshahbazker@wavecomp.com>

This should go to libsanitizer upstream.

> libsanitizer:
>         * asan/asan_mapping.h (ASAN_SHADOW_OFFSET_CONST): Set correct
>         offset for n32 ABI.
>
> Cherry-picked 12ec4fc5c3a19e6304b58775db1820892942efbc
> from https://github.com/MIPS/gcc
>
> Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com>
> Signed-off-by: Chao-ying Fu <cfu@mips.com>
> Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
> ---
>  libsanitizer/asan/asan_mapping.h | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/libsanitizer/asan/asan_mapping.h b/libsanitizer/asan/asan_mapping.h
> index 54890ca1789..7a6d94623b4 100644
> --- a/libsanitizer/asan/asan_mapping.h
> +++ b/libsanitizer/asan/asan_mapping.h
> @@ -65,6 +65,13 @@
>  // || `[0x0aaa0000, 0x0bff3fff]` || LowShadow  ||
>  // || `[0x00000000, 0x0aa9ffff]` || LowMem     ||
>  //
> +// Default Linux/MIPS64 n32 ABI mapping:
> +// || `[0x40000000, 0xffffffff]` || HighMem    ||
> +// || `[0x28000000, 0x3fffffff]` || HighShadow ||
> +// || `[0x24000000, 0x27ffffff]` || ShadowGap  ||
> +// || `[0x20000000, 0x23ffffff]` || LowShadow  ||
> +// || `[0x00000000, 0x1fffffff]` || LowMem     ||
> +//
>  // Default Linux/MIPS64 mapping:
>  // || `[0x4000000000, 0xffffffffff]` || HighMem    ||
>  // || `[0x2800000000, 0x3fffffffff]` || HighShadow ||
> @@ -169,7 +176,11 @@
>  #  if SANITIZER_ANDROID
>  #    define ASAN_SHADOW_OFFSET_DYNAMIC
>  #  elif defined(__mips__)
> -#    define ASAN_SHADOW_OFFSET_CONST 0x0aaa0000
> +#    if _MIPS_SIM == _ABIN32
> +#      define ASAN_SHADOW_OFFSET_CONST 0x20000000
> +#    else
> +#      define ASAN_SHADOW_OFFSET_CONST 0x0aaa0000
> +#    endif
>  #  elif SANITIZER_FREEBSD
>  #    define ASAN_SHADOW_OFFSET_CONST 0x40000000
>  #  elif SANITIZER_NETBSD
> --
> 2.34.1
  

Patch

diff --git a/libsanitizer/asan/asan_mapping.h b/libsanitizer/asan/asan_mapping.h
index 54890ca1789..7a6d94623b4 100644
--- a/libsanitizer/asan/asan_mapping.h
+++ b/libsanitizer/asan/asan_mapping.h
@@ -65,6 +65,13 @@ 
 // || `[0x0aaa0000, 0x0bff3fff]` || LowShadow  ||
 // || `[0x00000000, 0x0aa9ffff]` || LowMem     ||
 //
+// Default Linux/MIPS64 n32 ABI mapping:
+// || `[0x40000000, 0xffffffff]` || HighMem    ||
+// || `[0x28000000, 0x3fffffff]` || HighShadow ||
+// || `[0x24000000, 0x27ffffff]` || ShadowGap  ||
+// || `[0x20000000, 0x23ffffff]` || LowShadow  ||
+// || `[0x00000000, 0x1fffffff]` || LowMem     ||
+//
 // Default Linux/MIPS64 mapping:
 // || `[0x4000000000, 0xffffffffff]` || HighMem    ||
 // || `[0x2800000000, 0x3fffffffff]` || HighShadow ||
@@ -169,7 +176,11 @@ 
 #  if SANITIZER_ANDROID
 #    define ASAN_SHADOW_OFFSET_DYNAMIC
 #  elif defined(__mips__)
-#    define ASAN_SHADOW_OFFSET_CONST 0x0aaa0000
+#    if _MIPS_SIM == _ABIN32
+#      define ASAN_SHADOW_OFFSET_CONST 0x20000000
+#    else
+#      define ASAN_SHADOW_OFFSET_CONST 0x0aaa0000
+#    endif
 #  elif SANITIZER_FREEBSD
 #    define ASAN_SHADOW_OFFSET_CONST 0x40000000
 #  elif SANITIZER_NETBSD