aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/config
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-06-03 06:47:38 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-06-03 06:57:19 -0700
commit1949ad044a6979e176b0d0ebd5cfebbf162dd4f5 (patch)
tree71903e6c42db856c5fcb343a440e561647d34370 /ld/testsuite/config
parent37a141bfed4dd3c33d77c15dfde00e4b4f5b24c7 (diff)
downloadfsf-binutils-gdb-1949ad044a6979e176b0d0ebd5cfebbf162dd4f5.zip
fsf-binutils-gdb-1949ad044a6979e176b0d0ebd5cfebbf162dd4f5.tar.gz
fsf-binutils-gdb-1949ad044a6979e176b0d0ebd5cfebbf162dd4f5.tar.bz2
ld: Pass -fno-sanitize=all to tests with linker
When binutils is compiled with -fsanitize=undefined, many tests with linker, instead of $CC, fail with undefined symbol references to sanitize library. Define NOSANTIZE_CFLAGS to -fno-sanitize=all if target compiler supports it and compile such tests with $NOSANTIZE_CFLAGS. * testsuite/config/default.exp (NOSANTIZE_CFLAGS): New. * testsuite/ld-elf/linux-x86.exp: Add $NOSANTIZE_CFLAGS to tests with run_ld_link_exec_tests. * testsuite/ld-elf/shared.exp: Add $NOSANTIZE_CFLAGS to tests with run_ld_link_tests. * testsuite/ld-elf/tls.exp: Likewise. * testsuite/ld-elfweak/elfweak.exp: Add $NOSANTIZE_CFLAGS to tests with ld_link. * testsuite/ld-gc/gc.exp: Add $NOSANTIZE_CFLAGS to cflags. * testsuite/ld-plugin/lto.exp: Add $NOSANTIZE_CFLAGS to tests with run_ld_link_tests.a * testsuite/ld-plugin/plugin.exp: Append $NOSANTIZE_CFLAGS to CFLAGS. * testsuite/ld-selective/selective.exp: Add $NOSANTIZE_CFLAGS to cflags and cxxflags. * testsuite/ld-srec/srec.exp: Append $NOSANTIZE_CFLAGS to CC and CXX. * testsuite/ld-x86-64/plt-main-ibt-x32.dd: Updated for -fsanitize=undefined. * testsuite/ld-x86-64/plt-main-ibt.dd: Likewise. * testsuite/ld-x86-64/x86-64.exp: Add $NOSANTIZE_CFLAGS to tests with run_cc_link_tests and run_ld_link_tests.
Diffstat (limited to 'ld/testsuite/config')
-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 5b7ca7a..4f0b76d 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -579,3 +579,41 @@ if { ![info exists STATIC_PIE_LDFLAGS] } then {
set STATIC_PIE_LDFLAGS ""
}
}
+
+# Set NOSANTIZE_CFLAGS to "-fno-sanitize=all" if target compiler
+# supports it.
+
+if { ![info exists NOSANTIZE_CFLAGS] } then {
+ if { [check_compiler_available] } {
+ # Check if gcc supports -fno-sanitize=all.
+ 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 -fno-sanitize=all $src -o $output"]
+ remote_file host delete $src
+ remote_file host delete $output
+ file delete $src
+
+ if { $available == 1 } then {
+ set NOSANTIZE_CFLAGS "-fno-sanitize=all"
+ } else {
+ set NOSANTIZE_CFLAGS ""
+ }
+ } else {
+ set NOSANTIZE_CFLAGS ""
+ }
+}