X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Ftestsuite%2Fconfig%2Fdefault.exp;h=7998f4efb851e51d065cd6a52f8f395751fb6777;hb=8be5def63b0f2036312483dac8dd5a4fa2e91009;hp=7fa7911cc8e3fa1a37cc698bd9fb1ec4cadb64a0;hpb=4d095f5b5e57584133f85df42da2123e20834aec;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index 7fa7911cc8..7998f4efb8 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 {