diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-07-27 16:16:17 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-07-27 16:20:49 -0700 |
commit | 6f8ea6c424a3ceda065c39903065cfb251add37d (patch) | |
tree | 1473230a3f4cceeddbf6dc3643ee72eb286e932f /ld/testsuite/config | |
parent | 13e1dec8960122ec0329f74e5915503e14db5ea2 (diff) | |
download | gdb-6f8ea6c424a3ceda065c39903065cfb251add37d.zip gdb-6f8ea6c424a3ceda065c39903065cfb251add37d.tar.gz gdb-6f8ea6c424a3ceda065c39903065cfb251add37d.tar.bz2 |
Set NOPIE_CFLAGS and NOPIE_LDFLAGS
GCC 6 can be configured to generate PIE by default. But some linker
size tests expect non-PIE. This patch defines NOPIE_CFLAGS to
"-fno-PIE" and NOPIE_LDFLAGS to "-no-pie" if target compiler supports
them. Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS to linker size tests if
needed.
* config/default.exp (NOPIE_CFLAGS): New.
(NOPIE_LDFLAGS): Likewise.
* ld-size/size.exp (run_cc_link_tests): Add $NOPIE_CFLAGS and
$NOPIE_LDFLAGS if needed.
(run_ld_link_exec_tests): Add $NOPIE_CFLAGS if needed.
Diffstat (limited to 'ld/testsuite/config')
-rw-r--r-- | ld/testsuite/config/default.exp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index 5acc963..5b3e29f 100644 --- a/ld/testsuite/config/default.exp +++ b/ld/testsuite/config/default.exp @@ -313,3 +313,42 @@ if { ![info exists PLT_CFLAGS] } then { set PLT_CFLAGS "" } } + +# Set NOPIE_CFLAGS to "-fno-PIE" and NOPIE_LDFLAGS to "-no-pie" if +# target compiler supports them. + +if { ![info exists NOPIE_CFLAGS] || ![info exists NOPIE_LDFLAGS] } then { + if { [which $CC] != 0 } { + # Check if gcc supports -fno-PIE -no-pie. + 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 + remote_download host $src + set nopie_available [run_host_cmd_yesno "$CC" "$flags -fno-PIE -no-pie $src -o $output"] + remote_file host delete $src + remote_file host delete $output + file delete $src + + if { $nopie_available == 1 } then { + set NOPIE_CFLAGS "-fno-PIE" + set NOPIE_LDFLAGS "-no-pie" + } else { + set NOPIE_CFLAGS "" + set NOPIE_LDFLAGS "" + } + } else { + set NOPIE_CFLAGS "" + set NOPIE_LDFLAGS "" + } +} |