From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22312 invoked by alias); 11 Jan 2015 23:58:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22302 invoked by uid 89); 11 Jan 2015 23:58:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f182.google.com Received: from mail-yk0-f182.google.com (HELO mail-yk0-f182.google.com) (209.85.160.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 11 Jan 2015 23:58:41 +0000 Received: by mail-yk0-f182.google.com with SMTP id 131so8058121ykp.13 for ; Sun, 11 Jan 2015 15:58:39 -0800 (PST) X-Received: by 10.236.228.137 with SMTP id f9mr20476814yhq.34.1421020719451; Sun, 11 Jan 2015 15:58:39 -0800 (PST) Received: from gnu-tools-1.localdomain (76-220-57-190.lightspeed.sntcca.sbcglobal.net. [76.220.57.190]) by mx.google.com with ESMTPSA id n69sm9454817yha.27.2015.01.11.15.58.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Jan 2015 15:58:39 -0800 (PST) Received: by gnu-tools-1.localdomain (Postfix, from userid 1000) id A37581C4284; Sun, 11 Jan 2015 15:58:37 -0800 (PST) Date: Mon, 12 Jan 2015 00:25:00 -0000 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: [testsuite] PATCH: Add check_effective_target_pie Message-ID: <20150111235837.GA26961@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00631.txt.bz2 Hi, This patch adds check_effective_target_pie to check if the current multilib generatse PIE by default. I will submit other patches to use it. OK for trunk? Thanks. H.J. --- 2015-01-11 H.J. Lu * gcc.target/i386/pie.c: New test. * lib/target-supports.exp (check_profiling_available): Return 0 if PIE is enabled. (check_effective_target_pie): New. --- gcc/testsuite/gcc.target/i386/pie.c | 12 ++++++++++++ gcc/testsuite/lib/target-supports.exp | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pie.c diff --git a/gcc/testsuite/gcc.target/i386/pie.c b/gcc/testsuite/gcc.target/i386/pie.c new file mode 100644 index 0000000..0a9f5ee --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pie.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target pie } } */ +/* { dg-options "-O2" } */ + +int foo (void); + +int +main (void) +{ + return foo (); +} + +/* { dg-final { scan-assembler "foo@PLT" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f5c6db8..549bcdf 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -475,6 +475,11 @@ proc check_profiling_available { test_what } { } } + # Profiling don't work with -fPIE -pie. + if { [check_effective_target_pie] } { + return 0 + } + # Support for -p on solaris2 relies on mcrt1.o which comes with the # vendor compiler. We cannot reliably predict the directory where the # vendor compiler (and thus mcrt1.o) is installed so we can't @@ -1080,6 +1085,16 @@ proc check_effective_target_nonpic { } { }] } +# Return 1 if the current multilib generatse PIE by default. + +proc check_effective_target_pie { } { + return [check_no_compiler_messages pie assembly { + #ifndef __PIE__ + #error unsupported + #endif + }] +} + # Return 1 if the target does not use a status wrapper. proc check_effective_target_unwrapped { } { -- 1.9.3