From b765d4e375fe9067743c493c97f22879597e901c Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 16 May 2003 05:04:34 +0000 Subject: [PATCH] 2003-05-15 H.J. Lu * config/default.exp (gcc_ld_flag): New. Make the newly built linker available to gcc. * lib/ld-lib.exp (default_ld_simple_link): Pass $gcc_ld_flag to gcc. * ld-elfvers/vers.exp: Use "ld_simple_link $CC" to build shared libraries. * ld-elfvsb/elfvsb.exp: Likewise. * ld-elfweak/elfweak.exp: Likewise. * ld-shared/shared.exp: Likewise. * ld-elfvers/vers.exp: Use "-Wl,-rpath,." to build shared libraries. * ld-elfvsb/elfvsb.exp: Likewise. * ld-elfvsb/elfvsb.exp: Remove xfail for powerpc-*-linux*. * ld-elfweak/elfweak.exp: Use PIC for shared libraries. --- ld/testsuite/ChangeLog | 21 +++++++++++++++++++++ ld/testsuite/config/default.exp | 9 +++++++++ ld/testsuite/ld-elfvers/vers.exp | 8 +++----- ld/testsuite/ld-elfvsb/elfvsb.exp | 16 ++++------------ ld/testsuite/ld-elfweak/elfweak.exp | 34 +++++++++++++++++----------------- ld/testsuite/ld-shared/shared.exp | 6 +++--- ld/testsuite/lib/ld-lib.exp | 8 ++++++++ 7 files changed, 65 insertions(+), 37 deletions(-) diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 2196be6..cb4f33d 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,24 @@ +2003-05-15 H.J. Lu + + * config/default.exp (gcc_ld_flag): New. Make the newly built + linker available to gcc. + * lib/ld-lib.exp (default_ld_simple_link): Pass $gcc_ld_flag + to gcc. + + * ld-elfvers/vers.exp: Use "ld_simple_link $CC" to build shared + libraries. + * ld-elfvsb/elfvsb.exp: Likewise. + * ld-elfweak/elfweak.exp: Likewise. + * ld-shared/shared.exp: Likewise. + + * ld-elfvers/vers.exp: Use "-Wl,-rpath,." to build shared + libraries. + * ld-elfvsb/elfvsb.exp: Likewise. + + * ld-elfvsb/elfvsb.exp: Remove xfail for powerpc-*-linux*. + + * ld-elfweak/elfweak.exp: Use PIC for shared libraries. + 2003-05-13 Stephane Carrez * ld-m68hc11/link-hcs12.d: New test. diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index 432a1a8..e883e87 100644 --- a/ld/testsuite/config/default.exp +++ b/ld/testsuite/config/default.exp @@ -60,6 +60,15 @@ if {![file isdirectory tmpdir/gas]} then { } set gcc_gas_flag "-B[pwd]/tmpdir/gas/" +# Make a symlink from tmpdir/ld to the linker in the build tree, so +# that we can use a -B option to gcc to force it to use the newly +# built linker. +if {![file isdirectory tmpdir/ld]} then { + catch "exec mkdir tmpdir/ld" status + catch "exec ln -s ../../ld-new tmpdir/ld/ld" status +} +set gcc_ld_flag "-B[pwd]/tmpdir/ld/" + # The mips64-*-linux-gnu compiler defaults to the N32 ABI after # installed, but to the O32 ABI in the build tree, because of some # specs-file hacks. Make sure we use an ABI that is compatible with diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp index d15bdb9..1e5da66 100644 --- a/ld/testsuite/ld-elfvers/vers.exp +++ b/ld/testsuite/ld-elfvers/vers.exp @@ -581,7 +581,6 @@ proc build_vers_lib_pic { test source libname other mapfile verexp versymexp sym } proc test_ldfail { test flag source execname other mapfile whyfail } { - global ld global srcdir global subdir global exec_output @@ -617,7 +616,7 @@ proc test_ldfail { test flag source execname other mapfile whyfail } { set script_arg "$script $srcdir/$subdir/$mapfile" } - if {![ld_link $ld $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]} { + if {![ld_simple_link $CC $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]} { pass "$test" return } @@ -686,7 +685,6 @@ proc test_strip_vers_lib { test srclib libname verexp versymexp } { proc build_exec { test source execname flags solibname verexp versymexp symexp } { - global ld global srcdir global subdir global exec_output @@ -715,7 +713,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp } set solibname_lib $tmpdir/$solibname } - if {![ld_link $ld $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]} { + if {![ld_simple_link $CC $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]} { fail "$test" return } @@ -877,7 +875,7 @@ build_exec "vers16" vers16.c vers16 "" vers16a.so "" vers16.dsym "" # Test a weak versioned symbol. build_vers_lib_no_pic "vers17" vers17.c vers17 "" vers17.map vers17.ver vers17.dsym "" build_vers_lib_no_pic "vers18" vers18.c vers18 vers17.so vers18.map vers18.ver vers18.dsym vers18.sym -build_exec "vers19" vers19.c vers19 "-rpath ." vers18.so vers19.ver vers19.dsym "" +build_exec "vers19" vers19.c vers19 "-Wl,-rpath,." vers18.so vers19.ver vers19.dsym "" build_vers_lib_no_pic "vers20a" vers20.c vers20a "" vers20.map vers20a.ver vers20.dsym "" exec cp $tmpdir/vers20a.so $tmpdir/vers20b.so diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp index b5424fc..66546dc 100644 --- a/ld/testsuite/ld-elfvsb/elfvsb.exp +++ b/ld/testsuite/ld-elfvsb/elfvsb.exp @@ -91,7 +91,7 @@ set support_protected "no" if [istarget *-*-linux*] { if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] { - if [ld_link $ld $tmpdir/main "$tmpdir/main.o"] { + if [ld_simple_link $CC $tmpdir/main "$tmpdir/main.o"] { catch "exec $tmpdir/main" support_protected } } @@ -99,7 +99,7 @@ if [istarget *-*-linux*] { # The test procedure. proc visibility_test { visibility progname testname main sh1 sh2 dat args } { - global ld + global CC global srcdir global subdir global exec_output @@ -115,7 +115,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { set shared "-bM:SRE -bE:$tmpdir/xcoff.exp" } - if {![ld_simple_link $ld $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { + if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { if { [ string match $visibility "hidden_undef" ] && [regexp ".*/sh1.c.*: undefined reference to \`visibility\'" $link_output] && [regexp ".*/sh1.c.*: undefined reference to \`visibility_var\'" $link_output] } { @@ -138,7 +138,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { set rpath /lib:$tmpdir } - if ![ld_link $ld $tmpdir/$progname "-rpath $rpath $tmpdir/$main $tmpdir/$progname.so"] { + if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] { if { [ string match $visibility "hidden" ] && [regexp ".*/main.c.*: undefined reference to \`visibility\'" $link_output] && [regexp ".*/main.c.*: undefined reference to \`visibility_var\'" $link_output] } { @@ -247,10 +247,6 @@ proc visibility_run {visibility} { } else { setup_xfail "*-*-sunos4*" } - if { [ string match $visibility "hidden_weak" ] - || [ string match $visibility "protected_weak" ] } { - setup_xfail "powerpc-*-linux*" - } # Non-pic code uses name binding rules for applications to # reference variables by gp-relative relocs, which can't be @@ -345,10 +341,6 @@ proc visibility_run {visibility} { } else { setup_xfail "*-*-sunos4*" } - if { [ string match $visibility "hidden_weak" ] - || [ string match $visibility "protected_weak" ] } { - setup_xfail "powerpc-*-linux*" - } if { ![ string match $visibility "hidden_undef" ] && ![ string match $visibility "protected_undef" ] } { setup_xfail "ia64-*-linux*" diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp index fda1b37..8fc6832 100644 --- a/ld/testsuite/ld-elfweak/elfweak.exp +++ b/ld/testsuite/ld-elfweak/elfweak.exp @@ -270,7 +270,7 @@ proc objdump_dynsymstuff { objdump object expectfile } { } proc build_lib {test libname objs dynsymexp} { - global ld + global CC global objdump global tmpdir global shared @@ -282,7 +282,7 @@ proc build_lib {test libname objs dynsymexp} { set files "$files $tmpdir/$obj" } - if {![ld_link $ld $tmpdir/$libname.so "$shared $files"]} { + if {![ld_simple_link $CC $tmpdir/$libname.so "$shared $files"]} { fail $test return } @@ -295,7 +295,7 @@ proc build_lib {test libname objs dynsymexp} { } proc build_exec { test execname objs flags dat dynsymexp symexp} { - global ld + global CC global objdump global tmpdir global shared @@ -308,7 +308,7 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} { set files "$files $tmpdir/$obj" } - if {![ld_link $ld $tmpdir/$execname "$flags $files"]} { + if {![ld_simple_link $CC $tmpdir/$execname "$flags $files"]} { fail "$test" return } @@ -392,7 +392,7 @@ if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c $tmpdir/main.o] { return } -if {![ld_link $ld $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} { +if {![ld_simple_link $CC $tmpdir/libbar.so "$shared $tmpdir/bar.o"]} { fail "ELF weak" return } @@ -407,17 +407,17 @@ if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/foo1b.c $tmpdir/foo1b.o] return } -if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o] { +if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o] { unresolved "ELF weak" return } -if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o] { +if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o] { unresolved "ELF weak" return } -if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o] { +if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o] { unresolved "ELF weak" return } @@ -427,17 +427,17 @@ if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main1.c $tmpdir/main1.o] { return } -if {![ld_link $ld $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} { +if {![ld_simple_link $CC $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]} { fail "ELF weak" return } -if {![ld_link $ld $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} { +if {![ld_simple_link $CC $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]} { fail "ELF weak" return } -if {![ld_link $ld $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} { +if {![ld_simple_link $CC $tmpdir/libbar1a.so "$shared $tmpdir/bar1a.o $tmpdir/libfoo1a.so"]} { fail "ELF weak" return } @@ -448,8 +448,8 @@ build_lib "ELF DSO weak func first DSO" libfoo "foo.o libbar.so" dsow.dsym build_lib "ELF DSO weak func last DSO" libfoo "libbar.so foo.o" dsow.dsym build_exec "ELF weak func first" foo "main.o bar.o" "" strong "" strong.sym build_exec "ELF weak func last" foo "bar.o main.o" "" strong "" strong.sym -build_exec "ELF weak func first DSO" foo "main.o libbar.so" "-rpath ." weak weak.dsym "" -build_exec "ELF weak func last DSO" foo "libbar.so main.o" "-rpath ." weak weak.dsym "" +build_exec "ELF weak func first DSO" foo "main.o libbar.so" "-Wl,-rpath,." weak weak.dsym "" +build_exec "ELF weak func last DSO" foo "libbar.so main.o" "-Wl,-rpath,." weak weak.dsym "" build_lib "ELF DSO weak data first" libfoo "bar1a.o foo1a.o" dsodata.dsym build_lib "ELF DSO weak data last" libfoo "foo1a.o bar1a.o" dsodata.dsym @@ -461,7 +461,7 @@ build_exec "ELF weak data first" foo "main1.o bar1a.o foo1a.o" "" strongdata "" build_exec "ELF weak data last" foo "foo1a.o main1.o bar1a.o" "" strongdata "" strongdata.sym build_exec "ELF weak data first common" foo "main1.o bar1a.o foo1b.o" "" strongdata "" strongcomm.sym build_exec "ELF weak data last common" foo "foo1b.o main1.o bar1a.o" "" strongdata "" strongcomm.sym -build_exec "ELF weak data first DSO" foo "main1.o libbar1a.so libfoo1a.so" "-rpath ." weakdata weakdata.dsym "" -build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o libbar1a.so" "-rpath ." weakdata weakdata.dsym "" -build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-rpath ." weakdata weakdata.dsym "" -build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-rpath ." weakdata weakdata.dsym "" +build_exec "ELF weak data first DSO" foo "main1.o libbar1a.so libfoo1a.so" "-Wl,-rpath,." weakdata weakdata.dsym "" +build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o libbar1a.so" "-Wl,-rpath,." weakdata weakdata.dsym "" +build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-Wl,-rpath,." weakdata weakdata.dsym "" +build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,-rpath,." weakdata weakdata.dsym "" diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp index 0cc8332..251f25d 100644 --- a/ld/testsuite/ld-shared/shared.exp +++ b/ld/testsuite/ld-shared/shared.exp @@ -95,7 +95,7 @@ if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { # The test procedure. proc shared_test { progname testname main sh1 sh2 dat args } { - global ld + global CC global srcdir global subdir global exec_output @@ -110,7 +110,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { set shared "-bM:SRE -bE:$tmpdir/xcoff.exp" } - if {![ld_simple_link $ld $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { + if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { fail "$testname" return } @@ -123,7 +123,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { set rpath /lib:$tmpdir } - if ![ld_link $ld $tmpdir/$progname "-rpath $rpath $tmpdir/$main $tmpdir/$progname.so"] { + if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] { fail "$testname" return } diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index 82ae093..89a7481 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -154,6 +154,7 @@ proc default_ld_link { ld target objects } { proc default_ld_simple_link { ld target objects } { global host_triplet global link_output + global gcc_ld_flag if { [which $ld] == 0 } then { perror "$ld does not exist" @@ -166,6 +167,13 @@ proc default_ld_simple_link { ld target objects } { set flags "" } + # If we are compiling with gcc, we want to add gcc_ld_flag to + # flags. Rather than determine this in some complex way, we guess + # based on the name of the compiler. + if {[string match "*gcc*" $ld] || [string match "*++*" $ld]} then { + set flags "$gcc_ld_flag $flags" + } + verbose -log "$ld $flags -o $target $objects" catch "exec $ld $flags -o $target $objects" link_output -- 2.7.4