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 + } + # 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