From ed4f78fae8b9406f32cfe8cc47bd138aeb9d5540 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 13 Jan 2015 20:05:41 +0000 Subject: [PATCH] Add check_effective_target_pie * gcc.target/i386/pie.c: New test. * lib/target-supports.exp (check_effective_target_pie): New. From-SVN: r219553 --- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.target/i386/pie.c | 12 ++++++++++++ gcc/testsuite/lib/target-supports.exp | 10 ++++++++++ 3 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pie.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3263f13c58d..24e8b25de59 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-01-13 H.J. Lu + + * gcc.target/i386/pie.c: New test. + + * lib/target-supports.exp (check_effective_target_pie): New. + 2015-01-13 Jakub Jelinek PR rtl-optimization/64286 diff --git a/gcc/testsuite/gcc.target/i386/pie.c b/gcc/testsuite/gcc.target/i386/pie.c new file mode 100644 index 00000000000..0a9f5eea0af --- /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 f5c6db851fc..0ac96466d4b 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 { } { -- 2.30.2