public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [testsuite] PATCH: Add check_effective_target_pie
@ 2015-01-12  0:25 H.J. Lu
  2015-01-12 18:28 ` Jeff Law
  0 siblings, 1 reply; 23+ messages in thread
From: H.J. Lu @ 2015-01-12  0:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: Uros Bizjak

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

	* 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

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2015-02-11 16:45 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12  0:25 [testsuite] PATCH: Add check_effective_target_pie 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
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

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).