public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.
@ 2022-09-07  7:39 Lulu Cheng
  2022-09-07  8:02 ` Xi Ruoyao
  2022-09-07  9:58 ` [PATCH " Martin Liška
  0 siblings, 2 replies; 5+ messages in thread
From: Lulu Cheng @ 2022-09-07  7:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: xry111, xuchenghua, Lulu Cheng

Sorry, asan shadow offset is wrong in v1.

In the file asan_mapping.h line 207:
	#    define ASAN_SHADOW_OFFSET_CONST 0x0000400000000000

So it's should be 1<<46.

------------------------------------
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.
---
 gcc/config/loongarch/loongarch.cc             | 13 +++++++++++++
 gcc/testsuite/g++.target/loongarch/pr106828.C |  4 ++++
 2 files changed, 17 insertions(+)
 create mode 100644 gcc/testsuite/g++.target/loongarch/pr106828.C

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 10acf06ef79..424fa4487f8 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -6471,6 +6471,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"
@@ -6665,6 +6675,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'.  */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.
  2022-09-07  7:39 [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend Lulu Cheng
@ 2022-09-07  8:02 ` Xi Ruoyao
  2022-09-07  9:12   ` [commited PATCH " Lulu Cheng
  2022-09-07  9:58 ` [PATCH " Martin Liška
  1 sibling, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2022-09-07  8:02 UTC (permalink / raw)
  To: Lulu Cheng, gcc-patches; +Cc: xuchenghua

On Wed, 2022-09-07 at 15:39 +0800, Lulu Cheng wrote:
> Sorry, asan shadow offset is wrong in v1.
> 
> In the file asan_mapping.h line 207:
>         #    define ASAN_SHADOW_OFFSET_CONST 0x0000400000000000
> 
> So it's should be 1<<46.

LGTM.  I forgot to include this change in r13-2296 :(.

> 
> ------------------------------------
> 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.
> ---
>  gcc/config/loongarch/loongarch.cc             | 13 +++++++++++++
>  gcc/testsuite/g++.target/loongarch/pr106828.C |  4 ++++
>  2 files changed, 17 insertions(+)
>  create mode 100644 gcc/testsuite/g++.target/loongarch/pr106828.C
> 
> diff --git a/gcc/config/loongarch/loongarch.cc
> b/gcc/config/loongarch/loongarch.cc
> index 10acf06ef79..424fa4487f8 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -6471,6 +6471,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"
> @@ -6665,6 +6675,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'.  */

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [commited PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.
  2022-09-07  8:02 ` Xi Ruoyao
@ 2022-09-07  9:12   ` Lulu Cheng
  0 siblings, 0 replies; 5+ messages in thread
From: Lulu Cheng @ 2022-09-07  9:12 UTC (permalink / raw)
  To: Xi Ruoyao, gcc-patches; +Cc: xuchenghua


在 2022/9/7 下午4:02, Xi Ruoyao 写道:
> On Wed, 2022-09-07 at 15:39 +0800, Lulu Cheng wrote:
>> Sorry, asan shadow offset is wrong in v1.
>>
>> In the file asan_mapping.h line 207:
>>          #    define ASAN_SHADOW_OFFSET_CONST 0x0000400000000000
>>
>> So it's should be 1<<46.
> LGTM.  I forgot to include this change in r13-2296 :(.
pushed to r13-2510.:-)
>
>> ------------------------------------
>> 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.
>> ---
>>   gcc/config/loongarch/loongarch.cc             | 13 +++++++++++++
>>   gcc/testsuite/g++.target/loongarch/pr106828.C |  4 ++++
>>   2 files changed, 17 insertions(+)
>>   create mode 100644 gcc/testsuite/g++.target/loongarch/pr106828.C
>>
>> diff --git a/gcc/config/loongarch/loongarch.cc
>> b/gcc/config/loongarch/loongarch.cc
>> index 10acf06ef79..424fa4487f8 100644
>> --- a/gcc/config/loongarch/loongarch.cc
>> +++ b/gcc/config/loongarch/loongarch.cc
>> @@ -6471,6 +6471,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"
>> @@ -6665,6 +6675,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] 5+ messages in thread

* Re: [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.
  2022-09-07  7:39 [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend Lulu Cheng
  2022-09-07  8:02 ` Xi Ruoyao
@ 2022-09-07  9:58 ` Martin Liška
  2022-09-07 10:01   ` Lulu Cheng
  1 sibling, 1 reply; 5+ messages in thread
From: Martin Liška @ 2022-09-07  9:58 UTC (permalink / raw)
  To: Lulu Cheng, gcc-patches; +Cc: xuchenghua

On 9/7/22 09:39, Lulu Cheng wrote:
> |+ This value is taken from the file libsanitizer/asan/asan_mappint.h. */|

s/asan_mappint.h/asan_mapping.h

Cheers,
Martin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.
  2022-09-07  9:58 ` [PATCH " Martin Liška
@ 2022-09-07 10:01   ` Lulu Cheng
  0 siblings, 0 replies; 5+ messages in thread
From: Lulu Cheng @ 2022-09-07 10:01 UTC (permalink / raw)
  To: Martin Liška, gcc-patches; +Cc: xuchenghua

Sorry, I will correct this typo.

Thanks!

在 2022/9/7 下午5:58, Martin Liška 写道:
> On 9/7/22 09:39, Lulu Cheng wrote:
>> |+ This value is taken from the file libsanitizer/asan/asan_mappint.h. */|
> s/asan_mappint.h/asan_mapping.h
>
> Cheers,
> Martin


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-07 10:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07  7:39 [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend Lulu Cheng
2022-09-07  8:02 ` Xi Ruoyao
2022-09-07  9:12   ` [commited PATCH " Lulu Cheng
2022-09-07  9:58 ` [PATCH " Martin Liška
2022-09-07 10:01   ` Lulu Cheng

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).