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  <hongjiu...@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
+    }
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.

  }

+# Return 1 if the current multilib generatse PIE by default.
s/generatse/generates/

Waiting on answer to PIE vs pg question above prior to approving or requesting further refinement.

jeff

Reply via email to