public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2510] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend [PR106828].
@ 2022-09-07  9:08 LuluCheng
  0 siblings, 0 replies; only message in thread
From: LuluCheng @ 2022-09-07  9:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0067ba052b976431c49d6a86f2c9ede9938efcdf

commit r13-2510-g0067ba052b976431c49d6a86f2c9ede9938efcdf
Author: Lulu Cheng <chenglulu@loongson.cn>
Date:   Wed Sep 7 11:25:45 2022 +0800

    LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend [PR106828].
    
    gcc/ChangeLog:
    
            PR target/106828
            * config/loongarch/loongarch.cc (loongarch_asan_shadow_offset): New.
            (TARGET_ASAN_SHADOW_OFFSET): New.
    
    gcc/testsuite/ChangeLog:
    
            PR target/106828
            * g++.target/loongarch/pr106828.C: New test.

Diff:
---
 gcc/config/loongarch/loongarch.cc             | 13 +++++++++++++
 gcc/testsuite/g++.target/loongarch/pr106828.C |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index c9187bf81a7..98c0e26cdb9 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -6466,6 +6466,16 @@ loongarch_use_anchors_for_symbol_p (const_rtx symbol)
   return default_use_anchors_for_symbol_p (symbol);
 }
 
+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook.  */
+
+static unsigned HOST_WIDE_INT
+loongarch_asan_shadow_offset (void)
+{
+  /* We only have libsanitizer support for LOONGARCH64 at present.
+     This value is taken from the file libsanitizer/asan/asan_mappint.h.  */
+  return TARGET_64BIT ? (HOST_WIDE_INT_1 << 46) : 0;
+}
+
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@@ -6660,6 +6670,9 @@ loongarch_use_anchors_for_symbol_p (const_rtx symbol)
 #undef  TARGET_USE_ANCHORS_FOR_SYMBOL_P
 #define TARGET_USE_ANCHORS_FOR_SYMBOL_P loongarch_use_anchors_for_symbol_p
 
+#undef TARGET_ASAN_SHADOW_OFFSET
+#define TARGET_ASAN_SHADOW_OFFSET loongarch_asan_shadow_offset
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-loongarch.h"
diff --git a/gcc/testsuite/g++.target/loongarch/pr106828.C b/gcc/testsuite/g++.target/loongarch/pr106828.C
new file mode 100644
index 00000000000..190c1db715f
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/pr106828.C
@@ -0,0 +1,4 @@
+/* { dg-do-preprocess } */
+/* { dg-options "-mabi=lp64d -fsanitize=address" } */
+
+/* Tests whether the compiler supports compile option '-fsanitize=address'.  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-07  9:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07  9:08 [gcc r13-2510] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend [PR106828] LuluCheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).