@@ -304,6 +304,21 @@ set lto_link_elf_tests [list \
304304 [list "PR ld/13244" \
305305 "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib" "-O2 -fno-early-inlining -flto" \
306306 {pr13244.c} {{"readelf" {-s --wide} "pr13244.d"}} "pr13244.so" "c"] \
307+ [list "Build libpr15146a.a" \
308+ "$plug_opt" "-flto -O2" \
309+ {pr15146a.c} {} "lib15146a.a"] \
310+ [list "Build pr15146b.so" \
311+ "-shared" "-O2 -fpic" \
312+ {pr15146b.c} {} "pr15146b.so" "c"] \
313+ [list "Build pr15146c.so" \
314+ "-shared -Wl,--no-as-needed tmpdir/pr15146b.so" "-O2 -fpic $no_lto" \
315+ {pr15146c.c} {} "pr15146c.so" "c"] \
316+ [list "PR ld/15146 (1)" \
317+ "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146a.o tmpdir/pr15146c.so" "" \
318+ {dummy.c} {{"readelf" {-d} "pr15146.d"}} "pr15146a.exe"] \
319+ [list "Build libpr15146d.a" \
320+ "$plug_opt" "-flto -O2" \
321+ {pr15146d.c} {} "lib15146d.a"] \
307322 [list "Build libpr16746a.a" \
308323 "" "" \
309324 {pr16746a.c pr16746b.c} {} "lib15146a.a"] \
@@ -637,6 +652,13 @@ run_cc_link_tests $lto_compile_elf_tests
637652# Restrict these to ELF targets that support shared libs and PIC.
638653if { [is_elf_format] && [check_lto_shared_available] } {
639654 run_cc_link_tests $lto_link_elf_tests
655+ set testname "PR ld/15146 (2)"
656+ set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
657+ if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
658+ pass $testname
659+ } {
660+ fail $testname
661+ }
640662 set testname "PR ld/16746 (3)"
641663 set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
642664 if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
0 commit comments