[PATCH] ld: Add $NOSANTIZE_CFLAGS to linker tests

H.J. Lu hjl.tools@gmail.com
Wed Aug 26 18:32:26 GMT 2020


-fsanitize= can be used to build binutils with

$ CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined" .../configure --disable-werror

Since not all linker tests are compatible with -fsanitize=, pass
$NOSANTIZE_CFLAGS to disable -fsanitize= for such tests.

	* testsuite/ld-elf/indirect.exp: Append $NOSANTIZE_CFLAGS to CC.
	* testsuite/ld-elf/shared.exp: Likewise.
	* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
	* testsuite/ld-elfweak/elfweak.exp: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-plugin/plugin.exp: Likewise.
	* testsuite/ld-scripts/crossref.exp: Likewise.
---
 ld/ChangeLog                         |  12 +++
 ld/testsuite/ld-elf/indirect.exp     |   3 +
 ld/testsuite/ld-elf/shared.exp       | 126 +++++++++++++++++++--------
 ld/testsuite/ld-elfcomm/elfcomm.exp  |   6 +-
 ld/testsuite/ld-elfvers/vers.exp     |   7 +-
 ld/testsuite/ld-elfvsb/elfvsb.exp    |   6 +-
 ld/testsuite/ld-elfweak/elfweak.exp  |   6 +-
 ld/testsuite/ld-plugin/lto.exp       |  18 ++--
 ld/testsuite/ld-plugin/plugin.exp    |   6 +-
 ld/testsuite/ld-scripts/crossref.exp |   8 +-
 10 files changed, 141 insertions(+), 57 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 6624608033..8bdc015e6d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,15 @@
+2020-08-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* testsuite/ld-elf/indirect.exp: Append $NOSANTIZE_CFLAGS to CC.
+	* testsuite/ld-elf/shared.exp: Likewise.
+	* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
+	* testsuite/ld-elfvers/vers.exp: Likewise.
+	* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
+	* testsuite/ld-elfweak/elfweak.exp: Likewise.
+	* testsuite/ld-plugin/lto.exp: Likewise.
+	* testsuite/ld-plugin/plugin.exp: Likewise.
+	* testsuite/ld-scripts/crossref.exp: Likewise.
+
 2020-08-26  Alan Modra  <amodra@gmail.com>
 
 	PR 26499
diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp
index 8acae4d3c9..9451b21383 100644
--- a/ld/testsuite/ld-elf/indirect.exp
+++ b/ld/testsuite/ld-elf/indirect.exp
@@ -64,6 +64,9 @@ if {[check_lto_available]} {
    append cc_cmd " -fno-lto"
 }
 
+# Disable all sanitizers.
+append cc_cmd " $NOSANTIZE_CFLAGS"
+
 if { ![ld_compile $cc_cmd $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o]
      || ![ld_compile $cc_cmd $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o]
      || ![ld_compile "$cc_cmd -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o]
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 4de5b34183..66da7203df 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -749,15 +749,6 @@ set build_tests {
   {"Build needed3"
    "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
    {dummy.c} {} "needed3"}
-  {"Build libpr2404a.so"
-   "-shared" "-fPIC"
-   {pr2404a.c} {} "libpr2404a.so"}
-  {"Build libpr2404n.so"
-   "-shared -Wl,-z,now" "-fPIC"
-   {pr2404a.c} {} "libpr2404n.so"}
-  {"Build libpr2404b.a"
-   "" ""
-   {pr2404b.c} {} "libpr2404b.a"}
   {"Build rdynamic-1"
    "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
    {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
@@ -792,6 +783,34 @@ set build_tests {
    "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC"
    {pr18458b.c} {} "libpr18458b.so"}
 }
+
+run_cc_link_tests [list \
+    [list \
+	"Build libpr2404a.so" \
+	"-shared $NOSANTIZE_CFLAGS" \
+	"-fPIC $NOSANTIZE_CFLAGS" \
+	{pr2404a.c} \
+	{} \
+	"libpr2404a.so" \
+    ] \
+    [list \
+	"Build libpr2404n.so" \
+	"-shared -Wl,-z,now $NOSANTIZE_CFLAGS" \
+	"-fPIC $NOSANTIZE_CFLAGS" \
+	{pr2404a.c} \
+	{} \
+	"libpr2404n.so" \
+    ] \
+    [list \
+	"Build libpr2404b.a" \
+	"" \
+	"$NOSANTIZE_CFLAGS" \
+	{pr2404b.c} \
+	{} \
+	"libpr2404b.a" \
+    ] \
+]
+
 # pr19073.s uses .set, which has a different meaning on alpha.
 if { ![istarget alpha-*-*] } {
     append build_tests {
@@ -873,7 +892,7 @@ run_ld_link_tests [list \
 	{ pr22269-1.c } \
 	{{readelf -rW pr22269-1.rd}} \
 	"pr22269-1" \
-	"-fPIE -O2" \
+	"-fPIE -O2 $NOSANTIZE_CFLAGS" \
     ] \
 ]
 
@@ -1006,11 +1025,16 @@ set run_tests [list \
      "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
      {relmain.c} "relmain" "relmain.out" ] \
     [list "Run pr2404" \
-     "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
-     {dummy.c} "pr2404" "pr2404.out" ] \
+     "$NOSANTIZE_CFLAGS -Wl,--no-as-needed \
+      tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+     "" \
+     {dummy.c} "pr2404" "pr2404.out" \
+     "$NOSANTIZE_CFLAGS" ] \
     [list "Run pr2404n" \
-     "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
-     {dummy.c} "pr2404n" "pr2404.out" ] \
+     "$NOSANTIZE_CFLAGS -Wl,-z,now \
+      -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
+     {dummy.c} "pr2404n" "pr2404.out" \
+     "$NOSANTIZE_CFLAGS" ] \
     [list "Run pr18458" \
      "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
      {pr18458c.c} "pr18458" "pass.out" ] \
@@ -1126,14 +1150,29 @@ set build_cxx_tests {
   {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
    "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
    {dl3.cc} {} "libdl3c.so" "c++"}
-  {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
-   "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi"
-   {del.cc new.cc} {} "libnew1a.so" "c++"}
-  {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
-   "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
-   {del.cc new.cc} {} "libnew1b.so" "c++"}
 }
 
+run_cc_link_tests [list \
+    [list \
+	"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" \
+	"-shared $NOSANTIZE_CFLAGS -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" \
+	"-fPIC -ansi $NOSANTIZE_CFLAGS" \
+	{del.cc new.cc} \
+	{} \
+	"libnew1a.so" \
+	"c++" \
+    ] \
+    [list \
+	"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" \
+	"-shared $NOSANTIZE_CFLAGS -Wl,--dynamic-list-data,--dynamic-list-cpp-new" \
+	"-fPIC -ansi $NOSANTIZE_CFLAGS" \
+	{del.cc new.cc} \
+	{} \
+	"libnew1b.so" \
+	"c++" \
+    ] \
+]
+
 # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
 #    {"Run with libdl3b.so"
 #     "tmpdir/libdl3b.so" ""
@@ -1145,14 +1184,31 @@ set run_cxx_tests {
     {"Run with libdl3c.so"
      "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
      {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
-    {"Run with libnew1a.so"
-     "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
-     {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
-    {"Run with libnew1b.so"
-     "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
-     {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"}
 }
 
+run_ld_link_exec_tests [list \
+    [list \
+	"Run with libnew1a.so" \
+	"-Wl,--no-as-needed tmpdir/libnew1a.so $NOSANTIZE_CFLAGS" \
+	"" \
+	{dl5.cc} \
+	"dl5a" \
+	"dl5.out" \
+	"-ansi $NOSANTIZE_CFLAGS" \
+	"c++" \
+    ] \
+    [list \
+	"Run with libnew1b.so" \
+	"-Wl,--no-as-needed tmpdir/libnew1b.so $NOSANTIZE_CFLAGS" \
+	"" \
+	{dl5.cc} \
+	"dl5b" \
+	"dl5.out" \
+	"-ansi $NOSANTIZE_CFLAGS" \
+	"c++" \
+    ] \
+]
+
 run_cc_link_tests $build_cxx_tests
 run_ld_link_exec_tests $run_cxx_tests
 
@@ -1163,7 +1219,7 @@ if { [istarget *-*-linux*]
 	[list \
 	    "Build libpr2404b.a with PIE" \
 	    "" \
-	    "-fPIE" \
+	    "-fPIE $NOSANTIZE_CFLAGS" \
 	    { pr2404b.c } \
 	    {} \
 	    "libpr2404b.a" \
@@ -1249,21 +1305,21 @@ if { [istarget *-*-linux*]
 	] \
 	[list \
 	    "Run pr2404 with PIE" \
-	    "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
+	    "-pie $NOSANTIZE_CFLAGS -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
 	    "" \
 	    { dummy.c } \
 	    "pr2404pie" \
 	    "pr2404.out" \
-	    "-fPIE" \
+	    "-fPIE $NOSANTIZE_CFLAGS" \
 	] \
 	[list \
 	    "Run pr2404 with PIE (-z now)" \
-	    "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
+	    "-pie $NOSANTIZE_CFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
 	    "" \
 	    { dummy.c } \
 	    "pr2404pien" \
 	    "pr2404.out" \
-	    "-fPIE" \
+	    "-fPIE $NOSANTIZE_CFLAGS" \
 	] \
 	[list \
 	    "Run pr18718" \
@@ -1499,7 +1555,7 @@ if { ([istarget "*-*-linux*"]
 	    { pr23162a.c } \
 	    "" \
 	    "libpr23162a.so" \
-	    "-fPIC -O2" \
+	    "-fPIC -O2 $NOSANTIZE_CFLAGS" \
 	] \
 	[list \
 	    "Build pr23162a" \
@@ -1509,7 +1565,7 @@ if { ([istarget "*-*-linux*"]
 	    { pr23162b.c } \
 	    {{readelf {-rW} pr23162.rd}} \
 	    "pr23162a" \
-	    "-fPIC -O0" \
+	    "-fPIC -O0 $NOSANTIZE_CFLAGS" \
 	] \
 	[list \
 	    "Build libpr23162b.so" \
@@ -1519,7 +1575,7 @@ if { ([istarget "*-*-linux*"]
 	    { pr23162a.c } \
 	    "" \
 	    "libpr23162b.so" \
-	    "-fPIC -O2" \
+	    "-fPIC -O2 $NOSANTIZE_CFLAGS" \
 	] \
 	[list \
 	    "Build pr23162b" \
@@ -1529,7 +1585,7 @@ if { ([istarget "*-*-linux*"]
 	    { pr23162b.c } \
 	    {{readelf {-rW} pr23162.rd}} \
 	    "pr23162b" \
-	    "-fPIC -O0" \
+	    "-fPIC -O0 $NOSANTIZE_CFLAGS" \
 	] \
 	[list \
 	    "Build libpr23161a.so" \
diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
index d23929ea0b..88dbe46f3b 100644
--- a/ld/testsuite/ld-elfcomm/elfcomm.exp
+++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
@@ -169,9 +169,9 @@ if [istarget nios2*-*-*] {
 
 # Explicitly use "-fcommon" so that even if $CFLAGS includes
 # "-fno-common", these tests are compiled as expected.
-if {   ![ld_compile "$CC $CFLAGS -fcommon" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
-    || ![ld_compile "$CC $CFLAGS -fcommon" $srcdir/$subdir/common1b.c tmpdir/common1b.o]
-    || ![ld_compile "$CC $CFLAGS -Wa,--elf-stt-common=yes -fcommon" $srcdir/$subdir/common1b.c tmpdir/common1c.o] } {
+if {   ![ld_compile "$CC $CFLAGS -fcommon $NOSANTIZE_CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
+    || ![ld_compile "$CC $CFLAGS -fcommon $NOSANTIZE_CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o]
+    || ![ld_compile "$CC $CFLAGS $NOSANTIZE_CFLAGS -Wa,--elf-stt-common=yes -fcommon" $srcdir/$subdir/common1b.c tmpdir/common1c.o] } {
     unresolved $test1
     unresolved $test1
     return
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
index 0216b13b6e..7fd6270fae 100644
--- a/ld/testsuite/ld-elfvers/vers.exp
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -489,8 +489,9 @@ proc build_binary { shared pic test source libname other mapfile verexp versymex
     global CC
     global CFLAGS
     global script
+    global NOSANTIZE_CFLAGS
 
-    if ![ld_compile "$CC -S $pic $CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s]     {
+    if ![ld_compile "$CC -S $pic $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s]     {
 	unresolved "$test"
 	return
     }
@@ -687,6 +688,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
     global objdump
     global CC
     global CFLAGS
+    global NOSANTIZE_CFLAGS
 
     set shared "--shared --no-undefined-version"
     set script --version-script
@@ -697,6 +699,9 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
 	append cc_cmd " -fno-lto"
     }
 
+    # Disable all sanitizers.
+    append cc_cmd " $NOSANTIZE_CFLAGS"
+
     if ![ld_compile $cc_cmd $srcdir/$subdir/$source $tmpdir/$execname.s]     {
 	unresolved "$test"
 	return
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
index fda2416c6d..3a242d3527 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.exp
+++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
@@ -444,7 +444,7 @@ visibility_run protected_undef_def
 visibility_run protected_weak
 visibility_run normal
 
-if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
+if { ![ld_compile "$CC -g $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
     unresolved "common hidden symbol"
 } else {
     if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
@@ -454,10 +454,10 @@ if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
     }
 }
 
-if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
+if { ![ld_compile "$CC -g $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
     unresolved "weak hidden symbol"
 } else {
-   if { ![ld_compile "$CC -g $CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
+   if { ![ld_compile "$CC -g $CFLAGS $NOSANTIZE_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
 	unresolved "weak hidden symbol"
     } else {
 	if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
index 3481878014..355bfe7e0c 100644
--- a/ld/testsuite/ld-elfweak/elfweak.exp
+++ b/ld/testsuite/ld-elfweak/elfweak.exp
@@ -267,13 +267,14 @@ proc build_lib {test libname objs dynsymexp} {
     global shared
     global srcdir
     global subdir
+    global NOSANTIZE_CFLAGS
 
     set files ""
     foreach obj $objs {
       set files "$files $tmpdir/$obj"
     }
 
-    if {![ld_link $CC $tmpdir/$libname.so "$shared $files"]} {
+    if {![ld_link "$CC $NOSANTIZE_CFLAGS" $tmpdir/$libname.so "$shared $files"]} {
 	fail $test
 	return
     }
@@ -355,6 +356,9 @@ if {[check_lto_available]} {
    append cc_cmd " -fno-lto"
 }
 
+# Disable all sanitizers.
+append cc_cmd " $NOSANTIZE_CFLAGS"
+
 # Old version of GCC for MIPS default to enabling -fpic
 # and get confused if it is used on the command line.
 if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 6a37025db5..6bd2a6aa44 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -141,7 +141,7 @@ set lto_link_tests [list \
    "" "-flto -O2 $lto_fat $NOSANTIZE_CFLAGS" \
    {pr12758b.c} {} "libpr12758.a"] \
   [list "PR ld/12758" \
-   "$NOPIE_LDFLAGS -O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" \
+   "$NOPIE_LDFLAGS $NOSANTIZE_CFLAGS -O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" \
    "$NOSANTIZE_CFLAGS" \
    {dummy.c} {} "pr12758.exe"] \
   [list "Build libpr13183.a" \
@@ -458,10 +458,12 @@ set lto_link_symbol_tests [list \
    "-O2 -flto -fuse-linker-plugin tmpdir/lto-9.o" "" \
    {dummy.c} {{"nm" {-C} "lto-9.d"}} "lto-9.exe" "c++"] \
   [list "LTO 16a symbol" \
-   "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" "-flto" \
+   "-O2 $NOSANTIZE_CFLAGS -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin" \
+   "-flto $NOSANTIZE_CFLAGS" \
    {lto-16a.c} {{"nm" {} "lto-16a.d"}} "lto-16.exe" "c"] \
   [list "LTO 16b symbol" \
-   "-O2 -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" "-flto" \
+   "-O2 $NOSANTIZE_CFLAGS -Wl,-e,foo -u bar -nostdlib -flto -fuse-linker-plugin" \
+   "-flto $NOSANTIZE_CFLAGS" \
    {lto-16a.c lto-16b.c} {{"nm" {} "lto-16b.d"}} "lto-16b.exe" "c"] \
   [list "PR ld/13183" \
    "-O2 -flto -fuse-linker-plugin tmpdir/pr13183b.o tmpdir/libpr13183.a" "" \
@@ -667,7 +669,8 @@ if { [at_least_gcc_version 4 7] } {
 	run_cc_link_tests [list \
 	    [list \
 		"Build pr22721a.so" \
-		"-shared -nostdlib -nostartfiles -Wl,-version-script,pr22721.t" \
+		"-shared $NOSANTIZE_CFLAGS -nostdlib -nostartfiles \
+		 -Wl,-version-script,pr22721.t" \
 		"" \
 		{pr22721a.s} \
 		{} \
@@ -675,15 +678,16 @@ if { [at_least_gcc_version 4 7] } {
 	    ] \
 	    [list \
 		"Build pr22721b.o" \
-		"$plug_opt" \
+		"$plug_opt $NOSANTIZE_CFLAGS" \
 		"-O2 -fPIC -flto $lto_no_fat" \
 		{pr22721b.c} \
 	    ] \
 	    [list \
 		"Build PR ld/pr22721" \
 		"-O2 -flto -fuse-linker-plugin -nostdlib -nostartfiles \
-		-Wl,-e,_start tmpdir/pr22721b.o tmpdir/pr22721a.so" \
-		"" \
+		 $NOSANTIZE_CFLAGS \
+		 -Wl,-e,_start tmpdir/pr22721b.o tmpdir/pr22721a.so" \
+		"$NOSANTIZE_CFLAGS" \
 		{dummy.c} \
 		{} \
 		"pr22721.exe"
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index dc8f007397..5f6f21af20 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -295,9 +295,9 @@ if { !$can_compile || $failed_compile } {
 run_ld_link_tests $plugin_tests
 
 if { [is_elf_format] \
-     && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
-     && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
-     && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
+     && [ld_compile "$CC $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
+     && [ld_compile "$CC $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
+     && [ld_compile "$CC $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
     run_ld_link_tests $plugin_extra_elf_tests
 }
 
diff --git a/ld/testsuite/ld-scripts/crossref.exp b/ld/testsuite/ld-scripts/crossref.exp
index b2f72313e3..652a0df84c 100644
--- a/ld/testsuite/ld-scripts/crossref.exp
+++ b/ld/testsuite/ld-scripts/crossref.exp
@@ -63,8 +63,8 @@ if [istarget tic6x*-*-*] {
     set CFLAGS "-mno-dsbt -msdata=none"
 }
 
-if { ![ld_compile $CC "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
-     || ![ld_compile $CC "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
+if { ![ld_compile "$CC $NOSANTIZE_CFLAGS" "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
+     || ![ld_compile "$CC $NOSANTIZE_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
     unresolved $test1
     unresolved $test2
     set CFLAGS "$old_CFLAGS"
@@ -101,7 +101,7 @@ if [string match "" $exec_output] then {
 
 # Check cross references within a single object.
 
-if { ![ld_compile $CC "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
+if { ![ld_compile "$CC $NOSANTIZE_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
     unresolved $test2
     set CFLAGS "$old_CFLAGS"
     set CC "$old_CC"
@@ -126,7 +126,7 @@ if [string match "" $exec_output] then {
 
 # Check cross references for ld -r
 
-if { ![ld_compile $CC "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
+if { ![ld_compile "$CC $NOSANTIZE_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
     unresolved $test3
     set CFLAGS "$old_CFLAGS"
     set CC "$old_CC"
-- 
2.26.2



More information about the Binutils mailing list