+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
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]
{"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"}
"-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 {
{ pr22269-1.c } \
{{readelf -rW pr22269-1.rd}} \
"pr22269-1" \
- "-fPIE -O2" \
+ "-fPIE -O2 $NOSANTIZE_CFLAGS" \
] \
]
"-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" ] \
{"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" ""
{"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
[list \
"Build libpr2404b.a with PIE" \
"" \
- "-fPIE" \
+ "-fPIE $NOSANTIZE_CFLAGS" \
{ pr2404b.c } \
{} \
"libpr2404b.a" \
] \
[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" \
{ pr23162a.c } \
"" \
"libpr23162a.so" \
- "-fPIC -O2" \
+ "-fPIC -O2 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build pr23162a" \
{ pr23162b.c } \
{{readelf {-rW} pr23162.rd}} \
"pr23162a" \
- "-fPIC -O0" \
+ "-fPIC -O0 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build libpr23162b.so" \
{ pr23162a.c } \
"" \
"libpr23162b.so" \
- "-fPIC -O2" \
+ "-fPIC -O2 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build pr23162b" \
{ pr23162b.c } \
{{readelf {-rW} pr23162.rd}} \
"pr23162b" \
- "-fPIC -O0" \
+ "-fPIC -O0 $NOSANTIZE_CFLAGS" \
] \
[list \
"Build libpr23161a.so" \
# 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
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
}
global objdump
global CC
global CFLAGS
+ global NOSANTIZE_CFLAGS
set shared "--shared --no-undefined-version"
set script --version-script
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
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"] {
}
}
-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"] {
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
}
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 {
"" "-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" \
"-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" "" \
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} \
{} \
] \
[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"
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
}
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"
# 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"
# 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"