aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/config/default.exp
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-04-02 07:03:08 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-04-02 07:12:45 -0700
commit8be5def63b0f2036312483dac8dd5a4fa2e91009 (patch)
treee9944941e51e9b0c3f781b0bdd91ffb12d16706a /ld/testsuite/config/default.exp
parent4d095f5b5e57584133f85df42da2123e20834aec (diff)
downloadgdb-8be5def63b0f2036312483dac8dd5a4fa2e91009.zip
gdb-8be5def63b0f2036312483dac8dd5a4fa2e91009.tar.gz
gdb-8be5def63b0f2036312483dac8dd5a4fa2e91009.tar.bz2
ld: Add NOCF_PROTECTION_CFLAGS to turn off -fcf-protection
GCC in Ubuntu 20.04 enables -fcf-protection by default, which leads to FAIL: S-records FAIL: S-records with constructors FAIL: Build plt-main with -z bndplt FAIL: Build plt-main with PIE and -z bndplt FAIL: Build plt-main with -z bndplt -z now FAIL: Build plt-main with PIE and -z bndplt -z now on x86-64. Add NOCF_PROTECTION_CFLAGS to pass -fcf-protection=none on these tests. * testsuite/config/default.exp (NOCF_PROTECTION_CFLAGS): New. Set to "-fcf-protection=none" if target compiler supports it. * testsuite/ld-srec/srec.exp: Add $NOCF_PROTECTION_CFLAGS to CC and CXX. * testsuite/ld-x86-64/x86-64.exp: Add $NOCF_PROTECTION_CFLAGS to PLT BND tests.
Diffstat (limited to 'ld/testsuite/config/default.exp')
-rw-r--r--ld/testsuite/config/default.exp38
1 files changed, 38 insertions, 0 deletions
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 7fa7911..7998f4e 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -344,6 +344,44 @@ if { ![info exists NOPIE_CFLAGS] || ![info exists NOPIE_LDFLAGS] } then {
}
}
+# Set NOCF_PROTECTION_CFLAGS to "-fcf-protection=none" if target compiler
+# supports it.
+
+if { ![info exists NOCF_PROTECTION_CFLAGS] } then {
+ if { [check_compiler_available] } {
+ # Check if gcc supports -fcf-protection=none.
+ set flags ""
+ if [board_info [target_info name] exists cflags] {
+ append flags " [board_info [target_info name] cflags]"
+ }
+ if [board_info [target_info name] exists ldflags] {
+ append flags " [board_info [target_info name] ldflags]"
+ }
+
+ set basename "tmpdir/nopie[pid]"
+ set src ${basename}.c
+ set output ${basename}
+ set f [open $src "w"]
+ puts $f "int main (void) { return 0; }"
+ close $f
+ if [is_remote host] {
+ set src [remote_download host $src]
+ }
+ set nopie_available [run_host_cmd_yesno "$CC" "$flags -fcf-protection=none $src -o $output"]
+ remote_file host delete $src
+ remote_file host delete $output
+ file delete $src
+
+ if { $nopie_available == 1 } then {
+ set NOCF_PROTECTION_CFLAGS "-fcf-protection=none"
+ } else {
+ set NOCF_PROTECTION_CFLAGS ""
+ }
+ } else {
+ set NOCF_PROTECTION_CFLAGS ""
+ }
+}
+
# Set GNU2_CFLAGS to "-mtls-dialect=gnu2" if target compiler supports it.
if { ![info exists GNU2_CFLAGS] } then {