public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jeff Law <law@redhat.com>
Cc: Magnus Granberg <zorry@gentoo.org>, gcc-patches@gcc.gnu.org
Subject: Re: [testsuite] PATCH: Add check_effective_target_pie
Date: Tue, 13 Jan 2015 13:03:00 -0000	[thread overview]
Message-ID: <20150113125201.GA18558@gmail.com> (raw)
In-Reply-To: <54B444E4.1080700@redhat.com>

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 <law@redhat.com> 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  <hongjiu.lu@intel.com>

	* 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

  reply	other threads:[~2015-01-13 12:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12  0:25 H.J. Lu
2015-01-12 18:28 ` Jeff Law
2015-01-12 19:58   ` H.J. Lu
2015-01-12 19:59     ` Jeff Law
     [not found]       ` <CAMe9rOp1R-FewC1D9fODCe3ia82Ve8YxvfzHPBCaSa9zn4xi+Q@mail.gmail.com>
     [not found]         ` <54B42880.2040800@redhat.com>
2015-01-12 20:16           ` H.J. Lu
2015-01-12 22:01             ` Magnus Granberg
2015-01-12 22:12               ` Jeff Law
2015-01-13 13:03                 ` H.J. Lu [this message]
2015-01-13 19:45                   ` Jeff Law
2015-02-10 23:11                     ` Rainer Orth
2015-02-11 14:04                       ` H.J. Lu
2015-02-11 14:11                         ` Rainer Orth
2015-02-11 14:20                           ` H.J. Lu
2015-02-11 15:19                             ` Rainer Orth
2015-02-11 15:45                               ` H.J. Lu
2015-02-11 16:16                                 ` Rainer Orth
2015-02-11 16:45                                   ` H.J. Lu
2015-01-13 13:04                 ` [testsuite] PATCH: Check if -pg available H.J. Lu
2015-01-13 13:15                   ` H.J. Lu
2015-01-13 19:49                   ` Jeff Law
2015-01-13 20:47                     ` H.J. Lu
2015-01-13 21:14                       ` Jeff Law
2015-01-13 14:56                 ` [testsuite] PATCH: Add check_effective_target_pie H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150113125201.GA18558@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=zorry@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).