From patchwork Tue Sep 20 13:25:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Torbjorn SVENSSON X-Patchwork-Id: 1317 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1463688wrt; Tue, 20 Sep 2022 06:26:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yFCI9TyL9igz/5SSYOBdsUA8TdJ93rDr88y7ExVEnM0sFYgCrrPPeJH8c5Q1O9Z/DBbNY X-Received: by 2002:a17:907:320c:b0:77b:6f08:9870 with SMTP id xg12-20020a170907320c00b0077b6f089870mr16572879ejb.249.1663680387845; Tue, 20 Sep 2022 06:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663680387; cv=none; d=google.com; s=arc-20160816; b=e2mvRl79CqJi5Lbiz+yFNjFoAFVjCd+iobPK2looWzpwRgBPRO4C9pb93hinFuKiMx gyl54Xns1uyPKZqqKW59OHM/Pqot6l+gLJ/EPxRIRF5Bif7tTVEBGtTGtFRcfWSA2QNu zFbNXQd4BOweEemNEGFNbo/g1boGNUggtBkhJ1ivxaJ7U4AP8U4TKALLI2fLOjKHYNyv xLokDkjtbFgzhlL4Bon+UlEJaqUzdldoXcp0MC2NAomt4WCLusHOIThXoDWeLvnmZOGb WILQifj0yWsBHvtxcjKiMMwzaAmhrptT/I7ZQlVQFy+eO5iV+IBbCJDW/cz4sWX8SWeR 08Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=JCV/vyZAkBGcjy7n4k10R6jk+03etvjmhv+Ioplmr5A=; b=pXqFHcqDdCKfUw5G1FeHY0tRDIBinUBTkYI5lk0ni4ZAhCTzbeWpPcxzyNsBJ++WSw nSZoSl7nt7HAeUfIoaw4BZzrg/Zt8BneddcWSAZdcVciw0+uTtENIZJm/b+1jamK9+Fg fGZsT7WWyfWJas/s4mfKkxDYU+DOcti8nsxNNH73riFhoxzRQQqRUpQol1HTk3sJPSCk ABNu/MCBjfWvcPQpavinyVmoKfWt2UI9j0s6PMMABEsD6oJmk6rmog29O1VkwkTtraCm 4aygx+hYzQVwzBoBK9Vjix/3G3RNbiY7BQG9J6KIwCh9TwCX+rhXuxFLk799MfPBbXJN flrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fxvu4zLr; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id js19-20020a17090797d300b00780633dc7b8si1395771ejc.734.2022.09.20.06.26.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:26:27 -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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fxvu4zLr; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8568C3858295 for ; Tue, 20 Sep 2022 13:26:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8568C3858295 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663680386; bh=JCV/vyZAkBGcjy7n4k10R6jk+03etvjmhv+Ioplmr5A=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Fxvu4zLr5HIzYvbk2AKUzbpWHiNcWImEa1Tg4cW41BCGuv1XER/sclOHtnrU7i/dO ZU4EX2x4AN/dZhGikfTa49hrPIerUAZUgGDEzrzcSmlpX3uLz9uxnNNyUta8P7Zs+a s1rNVRrnhxoCTbmhsioy+m5vnWgVni5T4VjioawU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id 672243858C55 for ; Tue, 20 Sep 2022 13:25:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 672243858C55 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28KD5jwO030648; Tue, 20 Sep 2022 15:25:36 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3jn6g59r4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 15:25:36 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 936C610002A; Tue, 20 Sep 2022 15:25:35 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8E3E023153A; Tue, 20 Sep 2022 15:25:35 +0200 (CEST) Received: from jkgcxl0002.jkg.st.com (10.75.127.46) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 15:25:32 +0200 To: Subject: [PATCH v2] testsuite: Only run test on target if VMA == LMA Date: Tue, 20 Sep 2022 15:25:15 +0200 Message-ID: <20220920132515.844262-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_04,2022-09-20_02,2022-06-22_01 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP 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: , X-Patchwork-Original-From: =?utf-8?q?Torbj=C3=B6rn_SVENSSON_via_Gcc-patches?= From: Torbjorn SVENSSON Reply-To: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= Cc: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= 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?1744495326352940445?= X-GMAIL-MSGID: =?utf-8?q?1744495326352940445?= Checking that the triplet matches arm*-*-eabi (or msp430-*-*) is not enough to know if the execution will enter an endless loop, or if it will give a meaningful result. As the execution test only work when VMA and LMA are equal, make sure that this condition is met. 2022-09-16 Torbjörn SVENSSON gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_vma_equals_lma): New. * c-c++-common/torture/attr-noinit-1.c: Requre VMA == LMA to run. * c-c++-common/torture/attr-noinit-2.c: Likewise. * c-c++-common/torture/attr-noinit-3.c: Likewise. * c-c++-common/torture/attr-persistent-1.c: Likewise. * c-c++-common/torture/attr-persistent-3.c: Likewise. Co-Authored-By: Yvan ROUX Signed-off-by: Torbjörn SVENSSON --- .../c-c++-common/torture/attr-noinit-1.c | 3 +- .../c-c++-common/torture/attr-noinit-2.c | 3 +- .../c-c++-common/torture/attr-noinit-3.c | 3 +- .../c-c++-common/torture/attr-persistent-1.c | 3 +- .../c-c++-common/torture/attr-persistent-3.c | 3 +- gcc/testsuite/lib/target-supports.exp | 49 +++++++++++++++++++ 6 files changed, 59 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c b/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c index 877e7647ac9..f84eba0b649 100644 --- a/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c +++ b/gcc/testsuite/c-c++-common/torture/attr-noinit-1.c @@ -1,4 +1,5 @@ -/* { dg-do run } */ +/* { dg-do link } */ +/* { dg-do run { target { vma_equals_lma } } } */ /* { dg-require-effective-target noinit } */ /* { dg-skip-if "data LMA != VMA" { msp430-*-* } { "-mlarge" } } */ /* { dg-options "-save-temps" } */ diff --git a/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c b/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c index befa2a0bd52..4528b9e3cfa 100644 --- a/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c +++ b/gcc/testsuite/c-c++-common/torture/attr-noinit-2.c @@ -1,4 +1,5 @@ -/* { dg-do run } */ +/* { dg-do link } */ +/* { dg-do run { target { vma_equals_lma } } } */ /* { dg-require-effective-target noinit } */ /* { dg-options "-fdata-sections -save-temps" } */ /* { dg-skip-if "data LMA != VMA" { msp430-*-* } { "-mlarge" } } */ diff --git a/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c b/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c index 519e88a59a6..2f1745694c9 100644 --- a/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c +++ b/gcc/testsuite/c-c++-common/torture/attr-noinit-3.c @@ -1,4 +1,5 @@ -/* { dg-do run } */ +/* { dg-do link } */ +/* { dg-do run { target { vma_equals_lma } } } */ /* { dg-require-effective-target noinit } */ /* { dg-options "-flto -save-temps" } */ /* { dg-skip-if "data LMA != VMA" { msp430-*-* } { "-mlarge" } } */ diff --git a/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c b/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c index 72dc3c27192..b11a515cef8 100644 --- a/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c +++ b/gcc/testsuite/c-c++-common/torture/attr-persistent-1.c @@ -1,4 +1,5 @@ -/* { dg-do run } */ +/* { dg-do link } */ +/* { dg-do run { target { vma_equals_lma } } } */ /* { dg-require-effective-target persistent } */ /* { dg-skip-if "data LMA != VMA" { msp430-*-* } { "-mlarge" } } */ /* { dg-options "-save-temps" } */ diff --git a/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c b/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c index 3e4fd28618d..068a72af5c8 100644 --- a/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c +++ b/gcc/testsuite/c-c++-common/torture/attr-persistent-3.c @@ -1,4 +1,5 @@ -/* { dg-do run } */ +/* { dg-do link } */ +/* { dg-do run { target { vma_equals_lma } } } */ /* { dg-require-effective-target persistent } */ /* { dg-options "-flto -save-temps" } */ /* { dg-skip-if "data LMA != VMA" { msp430-*-* } { "-mlarge" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 703aba412a6..df8141a15d8 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -370,6 +370,55 @@ proc check_weak_override_available { } { return [check_weak_available] } +# Return 1 if VMA is equal to LMA for the .data section, 0 +# otherwise. Cache the result. + +proc check_effective_target_vma_equals_lma { } { + global tool + + return [check_cached_effective_target vma_equals_lma { + set src vma_equals_lma[pid].c + set exe vma_equals_lma[pid].exe + verbose "check_effective_target_vma_equals_lma compiling testfile $src" 2 + set f [open $src "w"] + puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n" + puts $f "int foo = 42; void main() {}" + close $f + set lines [${tool}_target_compile $src $exe executable ""] + file delete $src + + if [string match "" $lines] then { + # No error messages + + set objdump_name [find_binutils_prog objdump] + set output [remote_exec host "$objdump_name" "--section-headers --section=.data $exe"] + set output [lindex $output 1] + + remote_file build delete $exe + + # Example output of objdump: + #vma_equals_lma9059.exe: file format elf32-littlearm + # + #Sections: + #Idx Name Size VMA LMA File off Algn + # 6 .data 00000558 20000000 08002658 00020000 2**3 + # CONTENTS, ALLOC, LOAD, DATA + + # Capture LMA and VMA columns for .data section + if ![ regexp "\d*\d+\s+\.data\s+\d+\s+(\d+)\s+(\d+)" $output dummy vma lma ] { + verbose "Could not parse objdump output" 2 + return 0 + } else { + return [string equal $vma $lma] + } + } else { + remote_file build delete $exe + verbose "Could not determine if VMA is equal to LMA. Assuming not equal." 2 + return 0 + } + }] +} + # The "noinit" attribute is only supported by some targets. # This proc returns 1 if it's supported, 0 if it's not.