From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id E7C8A385022B for ; Wed, 7 Sep 2022 08:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E7C8A385022B Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1662537773; bh=pPyI/YzGiX4VyUQe+4EsBazyiNJq9yZstbc0R7w6EOA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Dsc2ABGfvySA8h7Lg1Tk94Xd13e469PdswlPScmv3pAmufdgr9WNXPk90sMhBhsGu d9Y6H0d3dE8dWbJIxYMHajoaFD3EliOujMxZpf27XUVupIR8kiQ31GVN/dMpR4lx25 kBJzDDxyrd+CdV7k65IE6Zer1eo8tEzk9YSCSeho= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 1925465C27; Wed, 7 Sep 2022 04:02:52 -0400 (EDT) Message-ID: <886a2abd8dfdaaf82ca6c2445f5ecb584121987f.camel@xry111.site> Subject: Re: [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend. From: Xi Ruoyao To: Lulu Cheng , gcc-patches@gcc.gnu.org Cc: xuchenghua@loongson.cn Date: Wed, 07 Sep 2022 16:02:51 +0800 In-Reply-To: <20220907073946.1102002-1-chenglulu@loongson.cn> References: <20220907073946.1102002-1-chenglulu@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.45.3 MIME-Version: 1.0 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,GIT_PATCH_0,LIKELY_SPAM_FROM,PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 2022-09-07 at 15:39 +0800, Lulu Cheng wrote: > Sorry, asan shadow offset is wrong in v1. >=20 > In the file asan_mapping.h line 207: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0#=C2=A0=C2=A0=C2=A0 defin= e ASAN_SHADOW_OFFSET_CONST 0x0000400000000000 >=20 > So it's should be 1<<46. LGTM. I forgot to include this change in r13-2296 :(. >=20 > ------------------------------------ > gcc/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PR target/106828 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* config/loongarch/loonga= rch.cc > (loongarch_asan_shadow_offset): New. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(TARGET_ASAN_SHADOW_OFFSE= T): New. >=20 > gcc/testsuite/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0PR target/106828 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* g++.target/loongarch/pr= 106828.C: New test. > --- > =C2=A0gcc/config/loongarch/loongarch.cc=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 13 +++++++++++++ > =C2=A0gcc/testsuite/g++.target/loongarch/pr106828.C |=C2=A0 4 ++++ > =C2=A02 files changed, 17 insertions(+) > =C2=A0create mode 100644 gcc/testsuite/g++.target/loongarch/pr106828.C >=20 > 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) > =C2=A0=C2=A0 return default_use_anchors_for_symbol_p (symbol); > =C2=A0} > =C2=A0 > +/* Implement the TARGET_ASAN_SHADOW_OFFSET hook.=C2=A0 */ > + > +static unsigned HOST_WIDE_INT > +loongarch_asan_shadow_offset (void) > +{ > +=C2=A0 /* We only have libsanitizer support for LOONGARCH64 at present. > +=C2=A0=C2=A0=C2=A0=C2=A0 This value is taken from the file > libsanitizer/asan/asan_mappint.h.=C2=A0 */ > +=C2=A0 return TARGET_64BIT ? (HOST_WIDE_INT_1 << 46) : 0; > +} > + > =C2=A0/* Initialize the GCC target structure.=C2=A0 */ > =C2=A0#undef TARGET_ASM_ALIGNED_HI_OP > =C2=A0#define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" > @@ -6665,6 +6675,9 @@ loongarch_use_anchors_for_symbol_p (const_rtx > symbol) > =C2=A0#undef=C2=A0 TARGET_USE_ANCHORS_FOR_SYMBOL_P > =C2=A0#define TARGET_USE_ANCHORS_FOR_SYMBOL_P > loongarch_use_anchors_for_symbol_p > =C2=A0 > +#undef TARGET_ASAN_SHADOW_OFFSET > +#define TARGET_ASAN_SHADOW_OFFSET loongarch_asan_shadow_offset > + > =C2=A0struct gcc_target targetm =3D TARGET_INITIALIZER; > =C2=A0 > =C2=A0#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=3Dlp64d -fsanitize=3Daddress" } */ > + > +/* Tests whether the compiler supports compile option '- > fsanitize=3Daddress'.=C2=A0 */ --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University