* [PATCH] ld: Pass -fno-sanitize=all to tests with linker
@ 2020-06-03 13:52 H.J. Lu
2020-06-04 7:19 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2020-06-03 13:52 UTC (permalink / raw)
To: binutils
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.
---
ld/ChangeLog | 25 ++++++++++++++
ld/testsuite/config/default.exp | 38 ++++++++++++++++++++++
ld/testsuite/ld-elf/linux-x86.exp | 3 +-
ld/testsuite/ld-elf/shared.exp | 13 ++++----
ld/testsuite/ld-elf/tls.exp | 4 ++-
ld/testsuite/ld-elfweak/elfweak.exp | 6 ++--
ld/testsuite/ld-gc/gc.exp | 4 ++-
ld/testsuite/ld-plugin/lto.exp | 12 ++++---
ld/testsuite/ld-plugin/plugin.exp | 4 +++
ld/testsuite/ld-selective/selective.exp | 5 +--
ld/testsuite/ld-srec/srec.exp | 7 ++--
ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd | 2 +-
ld/testsuite/ld-x86-64/plt-main-ibt.dd | 2 +-
ld/testsuite/ld-x86-64/x86-64.exp | 28 ++++++++++------
14 files changed, 121 insertions(+), 32 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 799f213153..a0d759797c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,28 @@
+2020-06-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ * 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.
+
2020-06-03 Fangrui Song <maskray@google.com>
H.J. Lu <hongjiu.lu@intel.com>
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 5b7ca7a939..4f0b76d831 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 ""
+ }
+}
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
index fef788ff23..39322df2b6 100644
--- a/ld/testsuite/ld-elf/linux-x86.exp
+++ b/ld/testsuite/ld-elf/linux-x86.exp
@@ -56,6 +56,7 @@ if { ![isnative] || ![check_compiler_available] } {
global PLT_CFLAGS
# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
global NOPIE_CFLAGS NOPIE_LDFLAGS
+global NOSANTIZE_CFLAGS
run_ld_link_exec_tests [list \
[list \
@@ -65,7 +66,7 @@ run_ld_link_exec_tests [list \
{ linux-x86.S pr23428.c dummy.s } \
"pr23428" \
"pass.out" \
- "$NOPIE_CFLAGS -fno-asynchronous-unwind-tables" \
+ "$NOPIE_CFLAGS $NOSANTIZE_CFLAGS -fno-asynchronous-unwind-tables" \
"asm" \
] \
]
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 5606c9937f..fe7a56de9a 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -33,6 +33,7 @@ if ![check_shared_lib_support] {
# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
global NOPIE_CFLAGS NOPIE_LDFLAGS
+global NOSANTIZE_CFLAGS
set old_ASFLAGS $ASFLAGS
@@ -1510,7 +1511,7 @@ if { ([istarget "*-*-linux*"]
{ pr23161a.c } \
{{readelf {--dyn-syms -rW} pr23161a.rd}} \
"libpr23161a.so" \
- "-fPIC -O2" \
+ "-fPIC -O2 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build pr23161a" \
@@ -1520,7 +1521,7 @@ if { ([istarget "*-*-linux*"]
{ pr23161b.c } \
{{readelf {--dyn-syms -rW} pr23161b.rd}} \
"pr23161a" \
- "-fPIC -O0" \
+ "-fPIC -O0 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build libpr23161b.so" \
@@ -1530,7 +1531,7 @@ if { ([istarget "*-*-linux*"]
{ pr23161a.c } \
{{readelf {--dyn-syms -rW} pr23161a.rd}} \
"libpr23161b.so" \
- "-fPIC -O2" \
+ "-fPIC -O2 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build pr23161b" \
@@ -1540,7 +1541,7 @@ if { ([istarget "*-*-linux*"]
{ pr23161b.c } \
{{readelf {--dyn-syms -rW} pr23161b.rd}} \
"pr23161b" \
- "-fPIC -O0" \
+ "-fPIC -O0 $NOSANTIZE_CFLAGS" \
] \
]
}
@@ -1556,7 +1557,7 @@ if { [istarget "i?86-*-*"]
{ pr23161c.c } \
{{readelf {--dyn-syms -rW} pr23161c.rd}} \
"libpr23161c.so" \
- "-fPIC -O2" \
+ "-fPIC -O2 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build pr23161c" \
@@ -1566,7 +1567,7 @@ if { [istarget "i?86-*-*"]
{ pr23161b.c } \
{{readelf {--dyn-syms -rW} pr23161d.rd}} \
"pr23161c" \
- "-fPIC -O0" \
+ "-fPIC -O0 $NOSANTIZE_CFLAGS" \
] \
]
}
diff --git a/ld/testsuite/ld-elf/tls.exp b/ld/testsuite/ld-elf/tls.exp
index 380d6505a8..352d7ecca2 100644
--- a/ld/testsuite/ld-elf/tls.exp
+++ b/ld/testsuite/ld-elf/tls.exp
@@ -39,6 +39,8 @@ if [istarget "sparc*-*-*"] {
append AFLAGS_PIC " -K PIC"
}
+global NOSANTIZE_CFLAGS
+
run_ld_link_tests [list \
[list \
"Build pr22263-1" \
@@ -48,6 +50,6 @@ run_ld_link_tests [list \
{ pr22263-1a.c pr22263-1b.c } \
{{readelf -r pr22263-1.rd}} \
"pr22263-1" \
- "-fPIE -O2" \
+ "-fPIE -O2 $NOSANTIZE_CFLAGS" \
] \
]
diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
index dc387672b9..f9e2b3ea72 100644
--- a/ld/testsuite/ld-elfweak/elfweak.exp
+++ b/ld/testsuite/ld-elfweak/elfweak.exp
@@ -65,6 +65,7 @@ set DOBJDUMP_FLAGS --dynamic-syms
set SOBJDUMP_FLAGS --syms
set shared "--shared -Wl,--no-as-needed"
+global NOSANTIZE_CFLAGS
#
# objdump_symstuff
@@ -306,13 +307,14 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
global srcdir
global subdir
global exec_output
+ global NOSANTIZE_CFLAGS
set files ""
foreach obj $objs {
set files "$files $tmpdir/$obj"
}
- if {![ld_link $CC $tmpdir/$execname "$flags $files"]} {
+ if {![ld_link $CC $tmpdir/$execname "$flags $NOSANTIZE_CFLAGS $files"]} {
fail "$test"
return
}
@@ -439,7 +441,7 @@ run_dump_test $srcdir/$subdir/size2
if {![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/alias.c $tmpdir/alias.o]
|| ![ld_link $CC $tmpdir/alias.so "$shared $tmpdir/alias.o"]
- || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/aliasmain.c $tmpdir/aliasmain.o]
+ || ![ld_compile "$CC $CFLAGS $NOSANTIZE_CFLAGS" $srcdir/$subdir/aliasmain.c $tmpdir/aliasmain.o]
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/weakref1.c $tmpdir/weakref1.o]
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/weakref2.c $tmpdir/weakref2.o]} then {
unresolved "ELF weak (alias)"
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 5913f1f125..16ded5d9ab 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -23,7 +23,9 @@ if ![check_gc_sections_available] {
return
}
-set cflags "-ffunction-sections -fdata-sections"
+global NOSANTIZE_CFLAGS
+
+set cflags "-ffunction-sections -fdata-sections $NOSANTIZE_CFLAGS"
set objfile "tmpdir/gc.o"
# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 8ffc03f01a..d888854e1f 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -38,6 +38,8 @@ set saved_CXXFLAGS "$CXXFLAGS"
regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS
regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS
+global NOSANTIZE_CFLAGS
+
proc restore_notify { } {
global saved_CFLAGS
global saved_CXXFLAGS
@@ -74,10 +76,11 @@ set lto_link_tests [list \
"-O2 -flto -fuse-linker-plugin" "-flto -fuse-linker-plugin" \
{lto-1a.c lto-1b.c} {} "lto-1.exe"] \
[list "Compile 2" \
- "" "-O2 -flto -fuse-linker-plugin" \
+ "" "-O2 -flto -fuse-linker-plugin $NOSANTIZE_CFLAGS" \
{lto-2.c} {} ""] \
[list "LTO 2" \
- "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" "" \
+ "-static -O2 -flto -fuse-linker-plugin tmpdir/lto-2.o -lm" \
+ "$NOSANTIZE_CFLAGS" \
{dummy.c} {} "lto-2.exe"] \
[list "Compile 3a" \
"" "-flto" \
@@ -143,10 +146,11 @@ set lto_link_tests [list \
"" "" \
{pr12758a.s} {} ""] \
[list "Build libpr12758.a" \
- "" "-flto -O2 $lto_fat" \
+ "" "-flto -O2 $lto_fat $NOSANTIZE_CFLAGS" \
{pr12758b.c} {} "libpr12758.a"] \
[list "PR ld/12758" \
- "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" \
+ "-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 "Compile PR ld/12760" \
"" "-g -O0" \
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index 8373e93861..381fc798d4 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -95,6 +95,9 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] }
set failed_compile 0
set _ ""
set plugin_nm_output ""
+global NOSANTIZE_CFLAGS
+set old_CFLAGS "$CFLAGS"
+append CFLAGS " $NOSANTIZE_CFLAGS"
if { $can_compile && \
(![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/func.c tmpdir/func.o] \
@@ -105,6 +108,7 @@ if { $can_compile && \
# Defer fail until we have list of tests set.
set failed_compile 1
}
+set CFLAGS "$old_CFLAGS"
set dotsym 0
if { $can_compile && !$failed_compile } {
diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp
index a12336bc2a..f25b0e20cf 100644
--- a/ld/testsuite/ld-selective/selective.exp
+++ b/ld/testsuite/ld-selective/selective.exp
@@ -46,8 +46,9 @@ set seltests {
{A::foo() B::foo() dropme1() dropme2()} {*-*-*}}
}
-set cflags "-w -O -ffunction-sections -fdata-sections"
-set cxxflags "-fno-exceptions -fno-rtti"
+global NOSANTIZE_CFLAGS
+set cflags "-w -O -ffunction-sections -fdata-sections $NOSANTIZE_CFLAGS"
+set cxxflags "-fno-exceptions -fno-rtti $NOSANTIZE_CFLAGS"
set ldflags "--gc-sections -Bstatic"
if [istarget mips*-*] {
diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
index da230fbca1..0d607f53d0 100644
--- a/ld/testsuite/ld-srec/srec.exp
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -351,11 +351,12 @@ if { ![check_compiler_available] } {
# Pass -fplt to CC and CXX since -fno-plt doesn't work with S-records
# tests. Also add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if PIE doesn't work
# with S-records. Also add $NOCF_PROTECTION_CFLAGS for S-records.
-global PLT_CFLAGS NOPIE_CFLAGS NOPIE_LDFLAGS NOCF_PROTECTION_CFLAGS
+# Also add $NOSANTIZE_CFLAGS for S-records.
+global PLT_CFLAGS NOPIE_CFLAGS NOPIE_LDFLAGS NOCF_PROTECTION_CFLAGS NOSANTIZE_CFLAGS
set old_CC "$CC"
-set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS"
+set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANTIZE_CFLAGS"
set old_CXX "$CXX"
-set CXX "$CXX $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS"
+set CXX "$CXX $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANTIZE_CFLAGS"
# S-records can't handle .note.gnu.property sections.
if { [is_elf_format] \
diff --git a/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd b/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd
index 7b5e174ef1..ab5e00d632 100644
--- a/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd
+++ b/ld/testsuite/ld-x86-64/plt-main-ibt-x32.dd
@@ -3,5 +3,5 @@ Disassembly of section .plt.got:
[a-f0-9]+ <[_a-z]+@plt>:
[ ]*[a-f0-9]+: f3 0f 1e fa endbr64
-[ ]*[a-f0-9]+: ff 25 .. .. 20 00 jmpq +\*0x20....\(%rip\) # ...... <[_a-z]+>
+[ ]*[a-f0-9]+: ff 25 .. .. 20 00 jmpq +\*0x20....\(%rip\) # ...... <.*>
#pass
diff --git a/ld/testsuite/ld-x86-64/plt-main-ibt.dd b/ld/testsuite/ld-x86-64/plt-main-ibt.dd
index 725f427e76..e2d6750e3a 100644
--- a/ld/testsuite/ld-x86-64/plt-main-ibt.dd
+++ b/ld/testsuite/ld-x86-64/plt-main-ibt.dd
@@ -3,5 +3,5 @@ Disassembly of section .plt.got:
[a-f0-9]+ <[_a-z]+@plt>:
[ ]*[a-f0-9]+: f3 0f 1e fa endbr64
-[ ]*[a-f0-9]+: f2 ff 25 .. .. 20 00 bnd jmpq \*0x20....\(%rip\) # ...... <[_a-z]+>
+[ ]*[a-f0-9]+: f2 ff 25 .. .. 20 00 bnd jmpq \*0x20....\(%rip\) # ...... <.*>
#pass
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 8bfb4f7ab8..cc2c6cc30a 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -748,13 +748,17 @@ global PLT_CFLAGS
global NOPIE_CFLAGS NOPIE_LDFLAGS
# Add $NOCF_PROTECTION_CFLAGS if -fcf-protection=none is required.
global NOCF_PROTECTION_CFLAGS
+global NOSANTIZE_CFLAGS
# Must be native with the C compiler
if { [isnative] && [check_compiler_available] } {
- run_cc_link_tests {
- {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
- {simple.c} {} "libsimple.a"}
- }
+ run_cc_link_tests [list \
+ [list \
+ "Helper X32 DSO from x86-64 object" "" \
+ "-m64 $NOSANTIZE_CFLAGS -fPIC -g" \
+ {simple.c} {} "libsimple.a" \
+ ] \
+ ]
set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
send_log "$convertx32\n"
@@ -765,12 +769,16 @@ if { [isnative] && [check_compiler_available] } {
return
}
- run_ld_link_tests {
- {"X32 DSO from x86-64 object"
- "-shared -melf32_x86_64 tmpdir/simple-x32.o" ""
- "--x32 -mx86-used-note=yes"
- {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
- }
+ run_ld_link_tests [list \
+ [list \
+ "X32 DSO from x86-64 object" \
+ "-shared -melf32_x86_64 tmpdir/simple-x32.o" \
+ "$NOSANTIZE_CFLAGS" \
+ "--x32 -mx86-used-note=yes" \
+ {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} \
+ "x86-64-x32" \
+ ] \
+ ]
run_cc_link_tests [list \
[list \
--
2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ld: Pass -fno-sanitize=all to tests with linker
2020-06-03 13:52 [PATCH] ld: Pass -fno-sanitize=all to tests with linker H.J. Lu
@ 2020-06-04 7:19 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2020-06-04 7:19 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On Wed, Jun 03, 2020 at 06:52:51AM -0700, H.J. Lu via Binutils wrote:
> --- a/ld/testsuite/ld-elf/linux-x86.exp
> +++ b/ld/testsuite/ld-elf/linux-x86.exp
> @@ -56,6 +56,7 @@ if { ![isnative] || ![check_compiler_available] } {
> global PLT_CFLAGS
> # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
> global NOPIE_CFLAGS NOPIE_LDFLAGS
> +global NOSANTIZE_CFLAGS
This isn't needed, nor are any of the other "global" statements
outside of a proc body. Let's fix them.
ld/
* testsuite/config/default.exp: Remove global directive outside
proc body.
* testsuite/ld-bootstrap/bootstrap.exp: Likewise.
* testsuite/ld-elf/compress.exp: Likewise.
* testsuite/ld-elf/elf.exp: Likewise.
* testsuite/ld-elf/exclude.exp: Likewise.
* testsuite/ld-elf/frame.exp: Likewise.
* testsuite/ld-elf/indirect.exp: Likewise.
* testsuite/ld-elf/linux-x86.exp: Likewise.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
* testsuite/ld-elfweak/elfweak.exp: Likewise.
* testsuite/ld-frv/fdpic.exp: Likewise.
* testsuite/ld-frv/tls.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-i386/i386.exp: Likewise.
* testsuite/ld-i386/no-plt.exp: Likewise.
* testsuite/ld-ifunc/ifunc.exp: Likewise.
* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
* testsuite/ld-nios2/nios2.exp: Likewise.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-powerpc/export-class.exp: Likewise.
* testsuite/ld-scripts/align.exp: Likewise.
* testsuite/ld-scripts/crossref.exp: Likewise.
* testsuite/ld-scripts/defined.exp: Likewise.
* testsuite/ld-scripts/overlay-size.exp: Likewise.
* testsuite/ld-scripts/provide.exp: Likewise.
* testsuite/ld-scripts/weak.exp: Likewise.
* testsuite/ld-selective/selective.exp: Likewise.
* testsuite/ld-sh/rd-sh.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.
* testsuite/ld-srec/srec.exp: Likewise.
* testsuite/ld-x86-64/mpx.exp: Likewise.
* testsuite/ld-x86-64/no-plt.exp: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
binutils/
* testsuite/binutils-all/i386/i386.exp
* testsuite/binutils-all/x86-64/objects.exp
* testsuite/binutils-all/x86-64/x86-64.exp
gas/
* testsuite/config/default.exp: Remove global directive outside
proc body.
* testsuite/gas/mep/complex-relocs.exp: Likewise.
* testsuite/gas/microblaze/relax_size.exp: Likewise.
* testsuite/gas/microblaze/reloc_sym.exp: Likewise.
* testsuite/gas/mt/relocs.exp: Likewise.
* testsuite/gas/rx/rx.exp: Likewise.
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 4f0b76d831..b2097ce7af 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -121,7 +121,6 @@ if {![info exists CXXFLAGS]} {
# \param Edit - The override command to perform.
# \param SavedStrings - Set to use for storing string representations.
-global env
# Only set up the environment variable if the user has not already provided one.
if {! [info exists env(CCC_OVERRIDE_OPTIONS)]} {
set env(CCC_OVERRIDE_OPTIONS) "#\
diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index ba51e50a02..43928fb648 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -29,8 +29,6 @@ if ![isnative] {
return
}
-global STATIC_LDFLAGS
-
# Determine if plugin support is present.
remote_exec host "$nm --help" "" "/dev/null" "plugin-support"
set tmp [file_contents "plugin-support"]
diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp
index db1993c415..8b55f86ea9 100644
--- a/ld/testsuite/ld-elf/compress.exp
+++ b/ld/testsuite/ld-elf/compress.exp
@@ -36,7 +36,6 @@ if { ![check_compiler_available] } {
return
}
-global as
if { ![ld_assemble $as "--compress-debug-sections $srcdir/$subdir/empty.s" tmpdir/empty.o ] } {
fail "linker compressed debug sections"
}
@@ -124,8 +123,6 @@ if { [catch {exec cmp tmpdir/libfoo.so tmpdir/libfoozlib.so}] } then {
pass "$test_name"
}
-global READELF
-
set test_name "Link -r with zlib compressed debug output"
set test zlibbegin
send_log "$READELF -S -W tmpdir/$test.o > tmpdir/$test.out\n"
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index 096b8af4f9..3ae769e3bf 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -121,7 +121,6 @@ if [is_underscore_target] {
set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
set ASFLAGS "$ASFLAGS -mx86-used-note=no"
diff --git a/ld/testsuite/ld-elf/exclude.exp b/ld/testsuite/ld-elf/exclude.exp
index 8ea1edff97..b9d24c2d4a 100644
--- a/ld/testsuite/ld-elf/exclude.exp
+++ b/ld/testsuite/ld-elf/exclude.exp
@@ -39,12 +39,6 @@ if { [istarget "tic6x-*-*"] } {
set as_opt "-mpic -mpid=near"
}
-global ar
-global as
-global ld
-global nm
-global nm_output
-
set test1 "ld link shared library"
set test2 "ld export symbols from archive"
set test3 "ld link shared library with --exclude-libs"
diff --git a/ld/testsuite/ld-elf/frame.exp b/ld/testsuite/ld-elf/frame.exp
index 2acc8ba84a..0bd0fb2d4c 100644
--- a/ld/testsuite/ld-elf/frame.exp
+++ b/ld/testsuite/ld-elf/frame.exp
@@ -55,9 +55,6 @@ if { [istarget "tic6x-*-*"] } {
set test1 "read-only .eh_frame section"
set test2 "read-only .gcc_except_table section"
-global as
-global ld
-
if { ![ld_assemble_flags $as $as_opt $srcdir/$subdir/tbss.s tmpdir/tbss.o ]
|| ![ld_assemble_flags $as $as_opt $srcdir/$subdir/frame.s tmpdir/frame.o] } {
unresolved "$test1"
diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp
index 7d5b494f04..acda39ef38 100644
--- a/ld/testsuite/ld-elf/indirect.exp
+++ b/ld/testsuite/ld-elf/indirect.exp
@@ -110,8 +110,6 @@ set build_tests {
run_cc_link_tests $build_tests
-global ld
-
set string ": final link failed: bad value"
set string1 ": local symbol \`foo\' in tmpdir/indirect1b.o is referenced by DSO"
@@ -128,8 +126,6 @@ set testname "Indirect symbol 2"
set cmd "$ld -shared -o tmpdir/indirect2.so tmpdir/indirect2.o"
check_link_message "$cmd" [list $string2] "$testname"
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
set run_tests {
{"Run with libindirect3c.so 1"
"-Wl,--no-as-needed tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
index 39322df2b6..eeaf4590e3 100644
--- a/ld/testsuite/ld-elf/linux-x86.exp
+++ b/ld/testsuite/ld-elf/linux-x86.exp
@@ -52,12 +52,6 @@ if { ![isnative] || ![check_compiler_available] } {
return
}
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-global NOSANTIZE_CFLAGS
-
run_ld_link_exec_tests [list \
[list \
"Run PR ld/23428 test" \
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index fe7a56de9a..da750b224a 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -31,10 +31,6 @@ if ![check_shared_lib_support] {
return
}
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-global NOSANTIZE_CFLAGS
-
set old_ASFLAGS $ASFLAGS
# This target requires extra GAS options when building code for shared
diff --git a/ld/testsuite/ld-elf/tls.exp b/ld/testsuite/ld-elf/tls.exp
index 352d7ecca2..15c382fcb4 100644
--- a/ld/testsuite/ld-elf/tls.exp
+++ b/ld/testsuite/ld-elf/tls.exp
@@ -39,8 +39,6 @@ if [istarget "sparc*-*-*"] {
append AFLAGS_PIC " -K PIC"
}
-global NOSANTIZE_CFLAGS
-
run_ld_link_tests [list \
[list \
"Build pr22263-1" \
diff --git a/ld/testsuite/ld-elf/tls_common.exp b/ld/testsuite/ld-elf/tls_common.exp
index f71e8ce9e0..3e14ccfc21 100644
--- a/ld/testsuite/ld-elf/tls_common.exp
+++ b/ld/testsuite/ld-elf/tls_common.exp
@@ -30,13 +30,6 @@ if { ![istarget *-*-linux*]
return
}
-global as
-global ld
-global READELF
-global srcdir
-global subdir
-global link_output
-
if { ![ld_assemble $as "--elf-stt-common=no $srcdir/$subdir/tls_common.s" tmpdir/tls_commona.o]
|| ![ld_assemble $as "--elf-stt-common=yes $srcdir/$subdir/tls_common.s" tmpdir/tls_commonb.o] } {
unresolved "tls_common"
diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
index 883cf6f4a9..d23929ea0b 100644
--- a/ld/testsuite/ld-elfcomm/elfcomm.exp
+++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
@@ -177,9 +177,6 @@ if { ![ld_compile "$CC $CFLAGS -fcommon" $srcdir/$subdir/common1a.c tmpdir/com
return
}
-global ld
-global link_output
-
set options "-r tmpdir/common1a.o tmpdir/common1b.o"
if { [ld_link $ld tmpdir/common1.o $options] } {
diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp
index f9e2b3ea72..dbc0c0321b 100644
--- a/ld/testsuite/ld-elfweak/elfweak.exp
+++ b/ld/testsuite/ld-elfweak/elfweak.exp
@@ -65,8 +65,6 @@ set DOBJDUMP_FLAGS --dynamic-syms
set SOBJDUMP_FLAGS --syms
set shared "--shared -Wl,--no-as-needed"
-global NOSANTIZE_CFLAGS
-
#
# objdump_symstuff
# Dump non-dynamic symbol stuff and make sure that it is sane.
diff --git a/ld/testsuite/ld-frv/fdpic.exp b/ld/testsuite/ld-frv/fdpic.exp
index 268f56b551..8d7e9176c5 100644
--- a/ld/testsuite/ld-frv/fdpic.exp
+++ b/ld/testsuite/ld-frv/fdpic.exp
@@ -23,11 +23,9 @@ if {![istarget frv*-*-*] || ![is_elf_format]} {
return
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
set ASFLAGS "$ASFLAGS -mfdpic"
-global LDFLAGS
set saved_LDFLAGS "$LDFLAGS"
set LDFLAGS "$LDFLAGS -melf32frvfd"
diff --git a/ld/testsuite/ld-frv/tls.exp b/ld/testsuite/ld-frv/tls.exp
index 5a14a27cc8..85eb370c69 100644
--- a/ld/testsuite/ld-frv/tls.exp
+++ b/ld/testsuite/ld-frv/tls.exp
@@ -23,11 +23,9 @@ if {![istarget frv*-*-*] || ![is_elf_format]} {
return
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
set ASFLAGS "$ASFLAGS -mfdpic"
-global LDFLAGS
set saved_LDFLAGS "$LDFLAGS"
set LDFLAGS "$LDFLAGS -melf32frvfd"
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 16ded5d9ab..97ccf6a7a9 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -23,14 +23,9 @@ if ![check_gc_sections_available] {
return
}
-global NOSANTIZE_CFLAGS
-
set cflags "-ffunction-sections -fdata-sections $NOSANTIZE_CFLAGS"
set objfile "tmpdir/gc.o"
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
if [istarget powerpc64*-*-*] {
# otherwise with -mcmodel=medium gcc we get XPASSes.
set cflags "$cflags -mminimal-toc"
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 2956c44c73..e1bbcddcd3 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -19,7 +19,6 @@
# MA 02110-1301, USA.
#
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
if { [is_elf_format] \
&& ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
@@ -581,9 +580,6 @@ proc undefined_weak {cflags ldflags} {
}
}
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-
# Must be Linux native with the C compiler
if { [isnative]
&& [istarget "i?86-*-linux*"]
@@ -1193,8 +1189,6 @@ if { [isnative]
undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
}
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
# Must be native with the C compiler and working IFUNC support,
if { [isnative]
&& [check_ifunc_available]
diff --git a/ld/testsuite/ld-i386/no-plt.exp b/ld/testsuite/ld-i386/no-plt.exp
index 54e41a2e26..44d1a398c5 100644
--- a/ld/testsuite/ld-i386/no-plt.exp
+++ b/ld/testsuite/ld-i386/no-plt.exp
@@ -39,9 +39,6 @@ if { ![check_compiler_available] } {
return
}
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
run_cc_link_tests [list \
[list \
"Build no-plt-func1.o no-plt-main1.o" \
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index 384ded0507..ce3434b30f 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -54,7 +54,6 @@ if ![check_shared_lib_support] {
return
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
set ASFLAGS "$ASFLAGS -mx86-used-note=no"
diff --git a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
index afbf84c35f..5160d67d24 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf-flags.exp
@@ -21,7 +21,6 @@ if {![istarget mips*-*-*] || ![is_elf_format]} {
return
}
-global ldemul
if {[istarget mips*-*-irix6*]} {
set ldemul "-melf32bsmip"
} elseif {[istarget mips*el-*-linux*]} {
diff --git a/ld/testsuite/ld-nios2/nios2.exp b/ld/testsuite/ld-nios2/nios2.exp
index b712e9e9e9..1af0c9212e 100644
--- a/ld/testsuite/ld-nios2/nios2.exp
+++ b/ld/testsuite/ld-nios2/nios2.exp
@@ -6,9 +6,6 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.d]] {
run_dump_test [file rootname $test]
}
-global link_output
-global ld
-
set test_name "NIOS2 Mixed R1 and R2 objects"
set test mixed1
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 5bd4c5f09b..383b1950bb 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -29,17 +29,11 @@ if { ![check_plugin_api_available]
return
}
-global INT128_CFLAGS
-
-global CFLAGS
-global CXXFLAGS
set saved_CFLAGS "$CFLAGS"
set saved_CXXFLAGS "$CXXFLAGS"
regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS
regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS
-global NOSANTIZE_CFLAGS
-
proc restore_notify { } {
global saved_CFLAGS
global saved_CXXFLAGS
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index 381fc798d4..dc8f007397 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -34,8 +34,6 @@ if { ![check_compiler_available] } {
pass "plugin API enabled"
-global base_dir
-
# Look for the name we can dlopen in the test plugin's libtool control script.
set plugin_name [file_contents "$base_dir/libldtestplug.la"]
set plugin_name [regsub "'.*" [regsub ".*dlname='" "$plugin_name" ""] ""]
@@ -95,7 +93,6 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] }
set failed_compile 0
set _ ""
set plugin_nm_output ""
-global NOSANTIZE_CFLAGS
set old_CFLAGS "$CFLAGS"
append CFLAGS " $NOSANTIZE_CFLAGS"
if { $can_compile && \
diff --git a/ld/testsuite/ld-powerpc/export-class.exp b/ld/testsuite/ld-powerpc/export-class.exp
index e244be3290..884c4ebd79 100644
--- a/ld/testsuite/ld-powerpc/export-class.exp
+++ b/ld/testsuite/ld-powerpc/export-class.exp
@@ -87,7 +87,6 @@ proc powerpc_export_class_test { abi endian emul } {
set abis { 32 be elf32ppclinux 32 le elf32lppclinux 64 be elf64ppc 64 le elf64lppc }
-global ld
catch "exec $ld --help | grep emulations" ldemul
foreach { abi endian emul } $abis {
diff --git a/ld/testsuite/ld-scripts/align.exp b/ld/testsuite/ld-scripts/align.exp
index 7d79bad2f3..1520fa333d 100644
--- a/ld/testsuite/ld-scripts/align.exp
+++ b/ld/testsuite/ld-scripts/align.exp
@@ -32,7 +32,6 @@ if ![ld_assemble $as $srcdir/$subdir/align.s tmpdir/align.o] {
}
# mingw on x86_64 targets need to set the image base to 0 to avoid auto image-basing.
-global LDFLAGS
set saved_LDFLAGS "$LDFLAGS"
if [istarget "x86_64-*-mingw*"] then {
set LDFLAGS "$LDFLAGS --image-base 0"
diff --git a/ld/testsuite/ld-scripts/crossref.exp b/ld/testsuite/ld-scripts/crossref.exp
index 75544ba362..b2f72313e3 100644
--- a/ld/testsuite/ld-scripts/crossref.exp
+++ b/ld/testsuite/ld-scripts/crossref.exp
@@ -38,12 +38,10 @@ if { ![check_compiler_available] } {
return
}
-global CFLAGS
set old_CFLAGS "$CFLAGS"
# Pass -fplt to CC since -fno-plt doesn't work with NOCROSSREFS tests.
# Also add $NOPIE_CFLAGS since PIE doesn't work NOCROSSREFS tests.
-global PLT_CFLAGS NOPIE_CFLAGS
set old_CC "$CC"
set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS"
diff --git a/ld/testsuite/ld-scripts/defined.exp b/ld/testsuite/ld-scripts/defined.exp
index bd046e2f89..404333fb8c 100644
--- a/ld/testsuite/ld-scripts/defined.exp
+++ b/ld/testsuite/ld-scripts/defined.exp
@@ -27,7 +27,6 @@ if ![ld_assemble $as $srcdir/$subdir/defined.s tmpdir/def.o] {
return
}
-global LDFLAGS
set saved_LDFLAGS "$LDFLAGS"
if [istarget "x86_64-*-mingw*"] then {
set LDFLAGS "$LDFLAGS --image-base 0"
@@ -62,7 +61,6 @@ if ![ld_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"
}
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
if { [is_elf_format] \
&& ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
diff --git a/ld/testsuite/ld-scripts/overlay-size.exp b/ld/testsuite/ld-scripts/overlay-size.exp
index 6aa233add2..ad7e0e442b 100644
--- a/ld/testsuite/ld-scripts/overlay-size.exp
+++ b/ld/testsuite/ld-scripts/overlay-size.exp
@@ -22,7 +22,6 @@ if ![is_elf_format] {
return
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
if { [is_elf_format] \
&& ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
diff --git a/ld/testsuite/ld-scripts/provide.exp b/ld/testsuite/ld-scripts/provide.exp
index 396ba025f7..a4aee5205b 100644
--- a/ld/testsuite/ld-scripts/provide.exp
+++ b/ld/testsuite/ld-scripts/provide.exp
@@ -30,7 +30,6 @@ if {[istarget "powerpc*-*-aix*"] || [istarget "rs6000-*-aix*"] || [is_aout_forma
return
}
-global LDFLAGS
set saved_LDFLAGS "$LDFLAGS"
if [istarget "x86_64-*-mingw*"] then {
set LDFLAGS "$LDFLAGS --image-base 0"
diff --git a/ld/testsuite/ld-scripts/weak.exp b/ld/testsuite/ld-scripts/weak.exp
index 1bb22426bc..b0ca4ab66e 100644
--- a/ld/testsuite/ld-scripts/weak.exp
+++ b/ld/testsuite/ld-scripts/weak.exp
@@ -43,7 +43,6 @@ if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
return
}
-global LDFLAGS
set saved_LDFLAGS "$LDFLAGS"
if [istarget "x86_64-*-mingw*"] then {
set LDFLAGS "$LDFLAGS --image-base 0"
diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp
index f25b0e20cf..bb16140ef2 100644
--- a/ld/testsuite/ld-selective/selective.exp
+++ b/ld/testsuite/ld-selective/selective.exp
@@ -46,7 +46,6 @@ set seltests {
{A::foo() B::foo() dropme1() dropme2()} {*-*-*}}
}
-global NOSANTIZE_CFLAGS
set cflags "-w -O -ffunction-sections -fdata-sections $NOSANTIZE_CFLAGS"
set cxxflags "-fno-exceptions -fno-rtti $NOSANTIZE_CFLAGS"
set ldflags "--gc-sections -Bstatic"
diff --git a/ld/testsuite/ld-sh/rd-sh.exp b/ld/testsuite/ld-sh/rd-sh.exp
index b6c9adfcd9..c01d50d6a9 100644
--- a/ld/testsuite/ld-sh/rd-sh.exp
+++ b/ld/testsuite/ld-sh/rd-sh.exp
@@ -31,8 +31,6 @@ if ![istarget sh*-*-*] {
return
}
-global ASFLAGS
-global LDFLAGS
set asflags_save "$ASFLAGS"
set ldflags_save "$LDFLAGS"
diff --git a/ld/testsuite/ld-size/size.exp b/ld/testsuite/ld-size/size.exp
index 20ebc01cc6..8a9459993a 100644
--- a/ld/testsuite/ld-size/size.exp
+++ b/ld/testsuite/ld-size/size.exp
@@ -53,9 +53,6 @@ if { ![check_compiler_available] } {
return
}
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
run_cc_link_tests [list \
[list \
"Build libsize-1.so" \
diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
index 0d607f53d0..69570a8a91 100644
--- a/ld/testsuite/ld-srec/srec.exp
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -352,7 +352,6 @@ if { ![check_compiler_available] } {
# tests. Also add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if PIE doesn't work
# with S-records. Also add $NOCF_PROTECTION_CFLAGS for S-records.
# Also add $NOSANTIZE_CFLAGS for S-records.
-global PLT_CFLAGS NOPIE_CFLAGS NOPIE_LDFLAGS NOCF_PROTECTION_CFLAGS NOSANTIZE_CFLAGS
set old_CC "$CC"
set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANTIZE_CFLAGS"
set old_CXX "$CXX"
diff --git a/ld/testsuite/ld-x86-64/mpx.exp b/ld/testsuite/ld-x86-64/mpx.exp
index 4cc5ed4d79..3a0f4b1469 100644
--- a/ld/testsuite/ld-x86-64/mpx.exp
+++ b/ld/testsuite/ld-x86-64/mpx.exp
@@ -36,9 +36,6 @@ if { ![check_compiler_available] } {
return
}
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-
run_cc_link_tests [list \
[list \
"Build libmpx1a.a" \
diff --git a/ld/testsuite/ld-x86-64/no-plt.exp b/ld/testsuite/ld-x86-64/no-plt.exp
index 4f8371c011..8a1667ba53 100644
--- a/ld/testsuite/ld-x86-64/no-plt.exp
+++ b/ld/testsuite/ld-x86-64/no-plt.exp
@@ -39,9 +39,6 @@ if { ![check_compiler_available] } {
return
}
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
run_cc_link_tests [list \
[list \
"Build no-plt-func1.o no-plt-main1.o" \
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index cc2c6cc30a..fd8fd34a77 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -34,7 +34,6 @@ if [istarget "*-*-nacl*"] {
set emul "elf_x86_64"
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
set ASFLAGS "$ASFLAGS -mx86-used-note=no"
@@ -265,9 +264,6 @@ if [istarget "*-*-nacl*"] {
run_ld_link_tests $x86_64tests
-global link_output
-global ld
-
set test_name "Mixed x86_64 and i386 input test 1"
set test mixed1
if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
@@ -742,14 +738,6 @@ proc undefined_weak {cflags ldflags} {
}
}
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-# Add $NOCF_PROTECTION_CFLAGS if -fcf-protection=none is required.
-global NOCF_PROTECTION_CFLAGS
-global NOSANTIZE_CFLAGS
-
# Must be native with the C compiler
if { [isnative] && [check_compiler_available] } {
run_cc_link_tests [list \
@@ -2148,7 +2136,6 @@ run_ld_link_tests [list \
]
# Linux only tests
-global LD_CLASS
if { "$LD_CLASS" == "64bit" } then {
# This test needs 64-bit linker.
run_dump_test "pr17618"
diff --git a/binutils/testsuite/binutils-all/i386/i386.exp b/binutils/testsuite/binutils-all/i386/i386.exp
index 238172d805..1ec07fb461 100644
--- a/binutils/testsuite/binutils-all/i386/i386.exp
+++ b/binutils/testsuite/binutils-all/i386/i386.exp
@@ -24,8 +24,6 @@ if {!([istarget "i*86-*-linux*"]
return
}
-global tempfile
-global copyfile
set tempfile tmpdir/i386temp.o
set copyfile tmpdir/i386copy
diff --git a/binutils/testsuite/binutils-all/x86-64/objects.exp b/binutils/testsuite/binutils-all/x86-64/objects.exp
index 5fc050d2cd..338f1d7366 100644
--- a/binutils/testsuite/binutils-all/x86-64/objects.exp
+++ b/binutils/testsuite/binutils-all/x86-64/objects.exp
@@ -22,9 +22,6 @@ if {!([istarget "x86_64-*-linux*"]
return
}
-global OBJCOPY
-global OBJCOPYFLAGS
-global READELF
set tempfile tmpdir/x86-64-object-temp.o
set copyfile tmpdir/x86-64-object-copy.o
diff --git a/binutils/testsuite/binutils-all/x86-64/x86-64.exp b/binutils/testsuite/binutils-all/x86-64/x86-64.exp
index ba03f32cd1..4e977c3c83 100644
--- a/binutils/testsuite/binutils-all/x86-64/x86-64.exp
+++ b/binutils/testsuite/binutils-all/x86-64/x86-64.exp
@@ -20,8 +20,6 @@ if {!([istarget "x86_64-*-linux*"]
return
}
-global tempfile
-global copyfile
set tempfile tmpdir/x86-64temp.o
set copyfile tmpdir/x86-64copy
diff --git a/gas/testsuite/config/default.exp b/gas/testsuite/config/default.exp
index f8e49d89aa..4a2a543753 100644
--- a/gas/testsuite/config/default.exp
+++ b/gas/testsuite/config/default.exp
@@ -16,12 +16,10 @@
load_lib gas-defs.exp
-global AS
if ![info exists AS] then {
set AS [findfile $base_dir/../as-new "../as-new" [transform as]]
}
-global ASFLAGS
if ![info exists ASFLAGS] then {
set ASFLAGS ""
}
diff --git a/gas/testsuite/gas/mep/complex-relocs.exp b/gas/testsuite/gas/mep/complex-relocs.exp
index 7eb9473599..081231174d 100644
--- a/gas/testsuite/gas/mep/complex-relocs.exp
+++ b/gas/testsuite/gas/mep/complex-relocs.exp
@@ -38,7 +38,6 @@ proc regexp_test { file1 file2 test } {
}
-global srcdir subdir
if [istarget mep*-*-*] {
# test that complex relocs between files work, generally
diff --git a/gas/testsuite/gas/microblaze/relax_size.exp b/gas/testsuite/gas/microblaze/relax_size.exp
index a733dc851a..6aace53745 100644
--- a/gas/testsuite/gas/microblaze/relax_size.exp
+++ b/gas/testsuite/gas/microblaze/relax_size.exp
@@ -13,7 +13,6 @@ proc regexp_test { file1 file2 test } {
if [regexp_diff $file1 $file2] then { fail $test } else { pass $test }
}
-global srcdir subdir
if [istarget microblaze*-*-elf] {
foreach file [lsort [glob -nocomplain -- $srcdir/$subdir/relax_size*.s]] {
set file [file rootname [file tail $file]]
diff --git a/gas/testsuite/gas/microblaze/reloc_sym.exp b/gas/testsuite/gas/microblaze/reloc_sym.exp
index 4fe96ff7ef..ee07f56259 100644
--- a/gas/testsuite/gas/microblaze/reloc_sym.exp
+++ b/gas/testsuite/gas/microblaze/reloc_sym.exp
@@ -33,7 +33,6 @@ proc regexp_test { file1 file2 test } {
}
-global srcdir subdir
if [istarget microblaze*-*-*] {
gas_test "reloc_strongsym.s" {-o reloc_strongsym.o} {} {assembling reloc_strongsym}
gas_test "reloc_weaksym.s" {-o reloc_weaksym.o} {} {assembling reloc_weaksym}
diff --git a/gas/testsuite/gas/mt/relocs.exp b/gas/testsuite/gas/mt/relocs.exp
index 2c650f43aa..0e200bea69 100644
--- a/gas/testsuite/gas/mt/relocs.exp
+++ b/gas/testsuite/gas/mt/relocs.exp
@@ -35,7 +35,6 @@ proc regexp_test { file1 file2 test } {
}
-global srcdir subdir
if [istarget mt-*] {
gas_test "relocs1.s" {-o relocs1.o} {} {assembling relocs1}
diff --git a/gas/testsuite/gas/rx/rx.exp b/gas/testsuite/gas/rx/rx.exp
index f9e4db4a66..8f5d510dde 100644
--- a/gas/testsuite/gas/rx/rx.exp
+++ b/gas/testsuite/gas/rx/rx.exp
@@ -21,7 +21,6 @@ if { ! [istarget rx-*-*] } {
return
}
-global ASFLAGS
set ASFLAGS "--mcpu=rxv3-dfpu"
foreach test [lsort [glob $srcdir/$subdir/*.sm]] {
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-04 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 13:52 [PATCH] ld: Pass -fno-sanitize=all to tests with linker H.J. Lu
2020-06-04 7:19 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).