From patchwork Wed Sep 7 07:39:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 1058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1015583wrt; Wed, 7 Sep 2022 00:44:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6yeaDCwiCKqFYWDKYdA0COe75IW5KhT8ku61Dw/hL/dZ8JbbntaqNpSSc9psFIOZc78xY8 X-Received: by 2002:a05:6402:26c6:b0:448:658e:5b32 with SMTP id x6-20020a05640226c600b00448658e5b32mr2047609edd.250.1662536672881; Wed, 07 Sep 2022 00:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662536672; cv=none; d=google.com; s=arc-20160816; b=qB3LO68pYAKhWEyV6MUgfkC2gQxayRUJYmkafpAFosC0gUNQusGh/JphNRtWuM0a13 yR5l3YFiZVrjbhdGJaBOF3qON0cNvC6tLe+a5Obzo0vTDTdsjGzE2QL+Ni2ZiTOzPT5t xzALBT6wxIiEx2sX/AMy466PjHb2XG9g1KIzFDO5Dc4+rVWrgnsMmVmcErTdxlh3UKB+ 4D6jNkcdNLratfFQgQns6kLmnv8DHotN9EwTgGcgIccslFcjJI8nEfXwJvdS6zuKdwx5 DWJgizC+x7tRSojV4rkoALNDctevXsw8o2Mtfp/Cr6u8sDVeExZho4vjsIJEoIIijB1v B+Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dmarc-filter :delivered-to; bh=Tq3PdJx/zw4XXWPYIcUHY49jCfPjSqwUH4iXzJruQG0=; b=WzNM/P9dBm63pdq+GUSHcQcIHl0sXATx6SdHa02xt0j8qQf45RxfyiE7YrqxaRiqgK EgITXBiQoe0Te9Ln5XYSE2qxQdEwDX2NbCVy7pp7wBqtdQcf41dKDxPtf2XW3LbKWu2b amsJcJQwiHfwsXcG3Zv9ohD8rfyLQiyLj0Z3aYwP5Qyroem8leXHqbmW1GpLT0iw2oBW XtJQ6B/7ZZ9AZAVqs6fyB3FiceN3HwQHwuCEyQBo7lIgaXNnECjSOhm5kLUfI3N958mK /KG5laArqQSINxWJyQJkG2sDIpEntYjnLenG/2nEzuCqMq5AyVvgXwpPQIWzE0bk2/oq V3bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ga38-20020a1709070c2600b0073d2fa02149si11569855ejc.553.2022.09.07.00.44.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 00:44:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 448863850400 for ; Wed, 7 Sep 2022 07:44:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 959EF3857C79 for ; Wed, 7 Sep 2022 07:43:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 959EF3857C79 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxX+C0SxhjcoATAA--.14301S2; Wed, 07 Sep 2022 15:43:52 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Subject: [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend. Date: Wed, 7 Sep 2022 15:39:47 +0800 Message-Id: <20220907073946.1102002-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxX+C0SxhjcoATAA--.14301S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uFWrXFWrtw15JFyUArW3Awb_yoW8KFW3pa sxZr17tr48JFZxKwn8t345XrsrArsrWa12v3WSkrW0ka13A34xZF1kGF93tayUJayUJry2 vw1xCa13XF4jyw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUka14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVCm-wCF 04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r 18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vI r41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr 1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvE x4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUywZ7UUUUU= X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xuchenghua@loongson.cn, Lulu Cheng Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743294866306963731?= X-GMAIL-MSGID: =?utf-8?q?1743296054291360605?= 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'. */