From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27721 invoked by alias); 13 Jan 2015 12:52:07 -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 27694 invoked by uid 89); 13 Jan 2015 12:52:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yh0-f44.google.com Received: from mail-yh0-f44.google.com (HELO mail-yh0-f44.google.com) (209.85.213.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 13 Jan 2015 12:52:05 +0000 Received: by mail-yh0-f44.google.com with SMTP id c41so1318927yho.3 for ; Tue, 13 Jan 2015 04:52:02 -0800 (PST) X-Received: by 10.236.1.97 with SMTP id 61mr26582088yhc.78.1421153522834; Tue, 13 Jan 2015 04:52:02 -0800 (PST) Received: from gnu-tools-1.localdomain (c-24-7-26-57.hsd1.ca.comcast.net. [24.7.26.57]) by mx.google.com with ESMTPSA id l33sm12722715yhq.6.2015.01.13.04.52.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2015 04:52:02 -0800 (PST) Received: by gnu-tools-1.localdomain (Postfix, from userid 1000) id 37F6D1C4166; Tue, 13 Jan 2015 04:52:01 -0800 (PST) Date: Tue, 13 Jan 2015 13:03:00 -0000 From: "H.J. Lu" To: Jeff Law Cc: Magnus Granberg , gcc-patches@gcc.gnu.org Subject: Re: [testsuite] PATCH: Add check_effective_target_pie Message-ID: <20150113125201.GA18558@gmail.com> References: <20150111235837.GA26961@gmail.com> <54B42880.2040800@redhat.com> <2219602.BYtQkL3Scp@laptop1.gw.ume.nu> <54B444E4.1080700@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <54B444E4.1080700@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00824.txt.bz2 On Mon, Jan 12, 2015 at 03:04:20PM -0700, Jeff Law wrote: > On 01/12/15 14:51, Magnus Granberg wrote: > >måndag 12 januari 2015 12.11.17 skrev H.J. Lu: > >>On Mon, Jan 12, 2015 at 12:03 PM, Jeff Law wrote: > >>>On 01/12/15 12:59, H.J. Lu wrote: > >>>>I don't know if -pg will work PIE on any targets. For Linux/x86 > >>>>the choices of crt1.o are > >>>> > >>>>%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} > >>>> > >>>>-shared, -pg and -pie are mutually exclusive. Those crt1 files are > >>>>only crt1 files provided by glibc. You can't even try -pg -pie on > >>>>Linux without changing glibc. > >>> > >>>You're totally missing the point. What I care about is *why*. > >>> > >With -pg it use gcrt1.o object file and that file is not compile with -fPIC. > >When you build a shared lib on x86_64 all the objects files need to be buiit > >with -fPIC else you get a error like that one abow and it is the same problems > >when you build bin with -fPIE and linke with -pie. > >Glibc do not provide one that is compile with -fPIC > Is there some reason why glibc could not provide gcrt1.o compiled with > -fPIC? That is a good question. We can compile gcrt1.o with -fPIC and it will work with both -pg and -pg -pie. I will open a glibc bug. Here is the updated patch without the check_profiling_available change. OK for trunk? Thanks. H.J. --- Subject: [PATCH 1/5] Add check_effective_target_pie Hi, This patch adds check_effective_target_pie to check if the current multilib generates PIE by default. Thanks. H.J. --- 2015-01-11 H.J. Lu * gcc.target/i386/pie.c: New test. * lib/target-supports.exp (check_effective_target_pie): New. --- gcc/testsuite/gcc.target/i386/pie.c | 12 ++++++++++++ gcc/testsuite/lib/target-supports.exp | 10 ++++++++++ 2 files changed, 22 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..0ac9646 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1080,6 +1080,16 @@ proc check_effective_target_nonpic { } { }] } +# Return 1 if the current multilib generates 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