From patchwork Fri Mar 11 03:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1604228 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ekBjydu1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KFBDK3dZQz9sG5 for ; Fri, 11 Mar 2022 14:26:23 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA91B3858419 for ; Fri, 11 Mar 2022 03:26:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA91B3858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1646969180; bh=kR5oXWqD95hsJ37HZ1SfhZPe/ydOW6PvBE5pi9a2ww4=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ekBjydu1MRWiLS2kQoT1OsFmRLatwYHJkWsOwcoUrawt3M8RZGIa7DZpem7TC84wb bLQwN5vkpQ87DbmZKlEJSk0IQZPlmglGyMrkBpza4oMuCk8/Hh2Jt6C7aByPhb8WkU xONyq4zOz0LEVjuEdX8FeL1CxAhdAhmgvBN9yxII= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mengyan1223.wang (mengyan1223.wang [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id A363A3858D39 for ; Fri, 11 Mar 2022 03:25:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A363A3858D39 Received: from [IPv6:240e:358:11f1:5f00:dc73:854d:832e:4] (unknown [IPv6:240e:358:11f1:5f00:dc73:854d:832e:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384)) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id B86A86637E; Thu, 10 Mar 2022 22:25:34 -0500 (EST) Message-ID: <7df02e5097a4b6ac9971ce581c2f2ad0d39817b1.camel@mengyan1223.wang> Subject: [PATCH 1/2] libsanitizer: cherry-pick db7bca28638e from upstream To: gcc-patches@gcc.gnu.org Date: Fri, 11 Mar 2022 11:25:28 +0800 User-Agent: Evolution 3.42.4 MIME-Version: 1.0 X-Spam-Status: No, score=-3038.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Cc: Richard Sandiford , YunQiang Su , Jeff Law Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" libsanitizer/ * sanitizer_common/sanitizer_atomic_clang.h: Ensures to only include sanitizer_atomic_clang_mips.h for O32. --- libsanitizer/sanitizer_common/sanitizer_atomic_clang.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h b/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h index fc13ca52dda..ccf18f0786d 100644 --- a/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h +++ b/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h @@ -96,8 +96,8 @@ inline bool atomic_compare_exchange_weak(volatile T *a, // This include provides explicit template instantiations for atomic_uint64_t // on MIPS32, which does not directly support 8 byte atomics. It has to // proceed the template definitions above. -#if defined(_MIPS_SIM) && defined(_ABIO32) - #include "sanitizer_atomic_clang_mips.h" +#if defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32 +# include "sanitizer_atomic_clang_mips.h" #endif #undef ATOMIC_ORDER From patchwork Fri Mar 11 03:27:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1604229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=NEXQq+nO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KFBGj1Bydz9sG5 for ; Fri, 11 Mar 2022 14:28:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 01E653858404 for ; Fri, 11 Mar 2022 03:28:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01E653858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1646969306; bh=Ure42iOck7G0eJk4U75cjbv1i9bXAY5HfHQnoopfkH8=; h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=NEXQq+nOWuIRy00iNmO7K/czhF3M8WBYAkLFJoYiMNhtumtFs4FqPJDWknl6iywXd 0aY3oRmboUezA2iTb5/m3RZYlrjcEZ7rONkdqnGG4GNFN76Cp5+KOEhDqZ0ul69trD 1sSeWQ0pO4SCwpJONzG6BguA4AtVyDtU2bF5yIMQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mengyan1223.wang (mengyan1223.wang [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 7E7953858C39 for ; Fri, 11 Mar 2022 03:27:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7E7953858C39 Received: from [IPv6:240e:358:11f1:5f00:dc73:854d:832e:4] (unknown [IPv6:240e:358:11f1:5f00:dc73:854d:832e:4]) (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@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id 87DE76637E; Thu, 10 Mar 2022 22:27:39 -0500 (EST) Message-ID: Subject: [PATCH 2/2] Enable libsanitizer build on mips64 To: gcc-patches@gcc.gnu.org Date: Fri, 11 Mar 2022 11:27:35 +0800 In-Reply-To: <7df02e5097a4b6ac9971ce581c2f2ad0d39817b1.camel@mengyan1223.wang> References: <7df02e5097a4b6ac9971ce581c2f2ad0d39817b1.camel@mengyan1223.wang> User-Agent: Evolution 3.42.4 MIME-Version: 1.0 X-Spam-Status: No, score=-3038.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_NUMSUBJECT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Cc: Richard Sandiford , YunQiang Su , Jeff Law Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Bootstrapped and regtested on mips64el-linux-gnuabi64. bootstrap-ubsan revealed 3 bugs (PR 104842, 104843, 104851). bootstrap-asan did not reveal any new bug. gcc/ * config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Define. * config/mips/mips.cc (mips_option_override): Make -fsanitize=address imply -fasynchronous-unwind-tables. This is needed by libasan for stack backtrace on MIPS. (mips_asan_shadow_offset): Return SUBTARGET_SHADOW_OFFSET. gcc/testsuite: * c-c++-common/asan/global-overflow-1.c: Skip for MIPS with some optimization levels because inaccurate debug info is causing dg-output mismatch on line numbers. * g++.dg/asan/large-func-test-1.C: Likewise. libsanitizer/ * configure.tgt: Enable build on mips64. --- gcc/config/mips/mips.cc | 9 ++++++++- gcc/config/mips/mips.h | 7 +++++++ gcc/testsuite/c-c++-common/asan/global-overflow-1.c | 1 + gcc/testsuite/g++.dg/asan/large-func-test-1.C | 1 + libsanitizer/configure.tgt | 4 ---- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 59eef515826..6b06c6380f6 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -19974,6 +19974,13 @@ mips_option_override (void) target_flags |= MASK_64BIT; } + /* -fsanitize=address needs to turn on -fasynchronous-unwind-tables in + order for tracebacks to be complete but not if any + -fasynchronous-unwind-table were already specified. */ + if (flag_sanitize & SANITIZE_USER_ADDRESS + && !global_options_set.x_flag_asynchronous_unwind_tables) + flag_asynchronous_unwind_tables = 1; + if ((target_flags_explicit & MASK_FLOAT64) != 0) { if (mips_isa_rev >= 6 && !TARGET_FLOAT64) @@ -22591,7 +22598,7 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align) static unsigned HOST_WIDE_INT mips_asan_shadow_offset (void) { - return 0x0aaa0000; + return SUBTARGET_SHADOW_OFFSET; } /* Implement TARGET_STARTING_FRAME_OFFSET. See mips_compute_frame_info diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 0029864fdcd..858bbba3a36 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -3463,3 +3463,10 @@ struct GTY(()) machine_function { && !TARGET_MICROMIPS && !TARGET_FIX_24K) #define NEED_INDICATE_EXEC_STACK 0 + +/* Define the shadow offset for asan. Other OS's can override in the + respective tm.h files. */ +#ifndef SUBTARGET_SHADOW_OFFSET +#define SUBTARGET_SHADOW_OFFSET \ + (POINTER_SIZE == 64 ? HOST_WIDE_INT_1 << 37 : HOST_WIDE_INT_C (0x0aaa0000)) +#endif diff --git a/gcc/testsuite/c-c++-common/asan/global-overflow-1.c b/gcc/testsuite/c-c++-common/asan/global-overflow-1.c index 1092a316681..ec412231be0 100644 --- a/gcc/testsuite/c-c++-common/asan/global-overflow-1.c +++ b/gcc/testsuite/c-c++-common/asan/global-overflow-1.c @@ -22,6 +22,7 @@ int main() { return res; } +/* { dg-skip-if "inaccurate debug info" { mips*-*-* } { "*" } { "-O0" } } */ /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */ /* { dg-output " #0 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*global-overflow-1.c:20|\[^\n\r]*:0|\[^\n\r]*\\+0x\[0-9a-z\]*)|\[(\])\[^\n\r]*(\n|\r\n|\r).*" } */ /* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of global variable" } */ diff --git a/gcc/testsuite/g++.dg/asan/large-func-test-1.C b/gcc/testsuite/g++.dg/asan/large-func-test-1.C index b42c09e3b0d..ac9deb898c8 100644 --- a/gcc/testsuite/g++.dg/asan/large-func-test-1.C +++ b/gcc/testsuite/g++.dg/asan/large-func-test-1.C @@ -35,6 +35,7 @@ int main() { delete x; } +// { dg-skip-if "inaccurate debug info" { mips*-*-* } { "-Os" } { "" } } // { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" } // { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } // { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt index 5a59ea6a1b5..fb89df4935c 100644 --- a/libsanitizer/configure.tgt +++ b/libsanitizer/configure.tgt @@ -54,10 +54,6 @@ case "${target}" in ;; arm*-*-linux*) ;; - mips*64*-*-linux*) - # This clause is only here to not match the supported mips*-*-linux*. - UNSUPPORTED=1 - ;; mips*-*-linux*) ;; aarch64*-*-linux*)