aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/lib/target-supports.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/lib/target-supports.exp')
-rw-r--r--gcc-4.9/gcc/testsuite/lib/target-supports.exp64
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/lib/target-supports.exp b/gcc-4.9/gcc/testsuite/lib/target-supports.exp
index 36a0b6c1b..8995fb0b3 100644
--- a/gcc-4.9/gcc/testsuite/lib/target-supports.exp
+++ b/gcc-4.9/gcc/testsuite/lib/target-supports.exp
@@ -869,6 +869,19 @@ proc check_effective_target_fpic { } {
return 0
}
+# Return 1 if -shared is supported, as in no warnings or errors
+# emitted, 0 otherwise.
+
+proc check_effective_target_shared { } {
+ # Note that M68K has a multilib that supports -fpic but not
+ # -fPIC, so we need to check both. We test with a program that
+ # requires GOT references.
+ return [check_no_compiler_messages shared executable {
+ extern int foo (void); extern int bar;
+ int baz (void) { return foo () + bar; }
+ } "-shared -fpic"]
+}
+
# Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
proc check_effective_target_pie { } {
@@ -5993,3 +6006,54 @@ proc force_conventional_output_for { test } {
}
}
+# Return 1 if the x86-64 target supports PIE with copy reloc, 0
+# otherwise. Cache the result.
+
+proc check_effective_target_pie_copyreloc { } {
+ global pie_copyreloc_available_saved
+ global tool
+ global GCC_UNDER_TEST
+
+ if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
+ return 0
+ }
+
+ # Need auto-host.h to check linker support.
+ if { ![file exists ../../auto-host.h ] } {
+ return 0
+ }
+
+ if [info exists pie_copyreloc_available_saved] {
+ verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
+ } else {
+ # Set up and compile to see if linker supports PIE with copy
+ # reloc. Include the current process ID in the file names to
+ # prevent conflicts with invocations for multiple testsuites.
+
+ set src pie[pid].c
+ set obj pie[pid].o
+
+ set f [open $src "w"]
+ puts $f "#include \"../../auto-host.h\""
+ puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
+ puts $f "# error Linker does not support PIE with copy reloc."
+ puts $f "#endif"
+ close $f
+
+ verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
+ set lines [${tool}_target_compile $src $obj object ""]
+
+ file delete $src
+ file delete $obj
+
+ if [string match "" $lines] then {
+ verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
+ set pie_copyreloc_available_saved 1
+ } else {
+ verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
+ set pie_copyreloc_available_saved 0
+ }
+ }
+
+ return $pie_copyreloc_available_saved
+}