From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7897) id 7E7A13857354; Fri, 30 Sep 2022 16:29:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E7A13857354 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664555378; bh=jg86t6ihYeWfYGSdU2Bepn9g/8GYFErC3nPJxUxnIGI=; h=From:To:Subject:Date:From; b=Kdwiepga83ZRjtQKIw2r2h2Q9oS23q4hyGXlugNQwQuHQNMUemx1LW9FcdSxntvBn vxBRoNLL1NnM4Ccnez1UvYyEMf7mfSg3tWOP2QVoMK0gp0YN+HPSTBpwrhvAFQzufp cpzN6fvoat6yEz4QcuK5CALxxB4WGCDOGUmbIENM= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Torbjorn Svensson To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2990] testsuite: Only run test on target if VMA == LMA X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 86291da0057d01efdaba71f28cad80b69dc703a4 X-Git-Newrev: 5fb71366da6ec5cd4dbc0262c6747804e319a7b7 Message-Id: <20220930162938.7E7A13857354@sourceware.org> Date: Fri, 30 Sep 2022 16:29:37 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5fb71366da6ec5cd4dbc0262c6747804e319a7b7 commit r13-2990-g5fb71366da6ec5cd4dbc0262c6747804e319a7b7 Author: Torbjörn SVENSSON Date: Fri Sep 16 19:49:01 2022 +0200 testsuite: Only run test on target if VMA == LMA 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. gcc/ChangeLog: * doc/sourcebuild.texi: Document new vma_equals_lma effective target check. 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 Diff: --- gcc/doc/sourcebuild.texi | 3 ++ gcc/testsuite/c-c++-common/torture/attr-noinit-1.c | 3 +- gcc/testsuite/c-c++-common/torture/attr-noinit-2.c | 3 +- gcc/testsuite/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 ++++++++++++++++++++++ 7 files changed, 62 insertions(+), 5 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 52357cc7aee..c81e2ffd43a 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2868,6 +2868,9 @@ Vector alignment is reachable for types of 32 bits or less. @item vector_alignment_reachable_for_64bit Vector alignment is reachable for types of 64 bits or less. +@item vma_equals_lma +Target generates executable with VMA equal to LMA for .data section. + @item wchar_t_char16_t_compatible Target supports @code{wchar_t} that is compatible with @code{char16_t}. 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 0a959c63c4a..7c9dd45f2a7 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.