From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9786 invoked by alias); 12 Jan 2015 19:29:15 -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 9777 invoked by uid 89); 12 Jan 2015 19:29:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f169.google.com Received: from mail-ob0-f169.google.com (HELO mail-ob0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 12 Jan 2015 19:29:13 +0000 Received: by mail-ob0-f169.google.com with SMTP id vb8so23949101obc.0 for ; Mon, 12 Jan 2015 11:29:12 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.202.191.194 with SMTP id p185mr17558850oif.128.1421090951919; Mon, 12 Jan 2015 11:29:11 -0800 (PST) Received: by 10.76.185.7 with HTTP; Mon, 12 Jan 2015 11:29:11 -0800 (PST) In-Reply-To: <54B40DCD.5010301@redhat.com> References: <20150111235837.GA26961@gmail.com> <54B40DCD.5010301@redhat.com> Date: Mon, 12 Jan 2015 19:58:00 -0000 Message-ID: Subject: Re: [testsuite] PATCH: Add check_effective_target_pie From: "H.J. Lu" To: Jeff Law Cc: GCC Patches , Uros Bizjak Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00727.txt.bz2 On Mon, Jan 12, 2015 at 10:09 AM, Jeff Law wrote: > On 01/11/15 16:58, H.J. Lu wrote: >> >> 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 >> + } > > Is this an inherent restriction of -fPIE, or is it merely an implementation > detail? If the latter, is that implementation detail a target issue? ie, > could we have a target that supports profiling in conjunction with -fPIE? > If so, then this test seems too restrictive. [hjl@gnu-6 tmp]$ gcc -pie -fPIE -pg h.c /usr/local/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/gcrt1.o: relocation R_X86_64_32S against `__libc_csu_fini' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/gcrt1.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status [hjl@gnu-6 tmp]$ There is no crt1.o from glibc to support -pg -pie -fPIE. I don't know if other targets support -pie -fPIE. >> } >> >> +# Return 1 if the current multilib generatse PIE by default. > > s/generatse/generates/ I will fix it. > Waiting on answer to PIE vs pg question above prior to approving or > requesting further refinement. Sure. -- H.J.