# Basic expect script for LD Regression Tests
-# Copyright (C) 1993-2019 Free Software Foundation, Inc.
+# Copyright (C) 1993-2020 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
}
}
+# 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/available[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 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 { $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 {