+2003-05-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ * 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 <stcarrez@nerim.fr>
* ld-m68hc11/link-hcs12.d: New test.
}
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
}
proc test_ldfail { test flag source execname other mapfile whyfail } {
- global ld
global srcdir
global subdir
global exec_output
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
}
proc build_exec { test source execname flags solibname verexp versymexp symexp } {
- global ld
global srcdir
global subdir
global exec_output
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
}
# 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
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
}
}
# 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
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] } {
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] } {
} 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
} 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*"
}
proc build_lib {test libname objs dynsymexp} {
- global ld
+ global CC
global objdump
global tmpdir
global shared
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
}
}
proc build_exec { test execname objs flags dat dynsymexp symexp} {
- global ld
+ global CC
global objdump
global tmpdir
global shared
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
}
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
}
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
}
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
}
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
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 ""
# The test procedure.
proc shared_test { progname testname main sh1 sh2 dat args } {
- global ld
+ global CC
global srcdir
global subdir
global exec_output
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
}
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
}
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"
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