return $flags
}
-# Link a program using ld.
+# Link a program using ld
#
proc default_ld_link { ld target objects } {
- global HOSTING_EMU
- global HOSTING_CRT0
- global HOSTING_SCRT0
- global HOSTING_LIBS
- global HOSTING_SLIBS
- global LIBS
- global host_triplet
- global link_output
- global exec_output
-
- if { [ string match "* -pie *" $objects ] } {
- set objs "$HOSTING_SCRT0 $objects"
- set libs "$LIBS $HOSTING_SLIBS"
- } else {
- set objs "$HOSTING_CRT0 $objects"
- set libs "$LIBS $HOSTING_LIBS"
- }
-
- if [is_endian_output_format $objects] then {
- set flags [big_or_little_endian]
- } else {
- set flags ""
- }
-
- remote_file host delete $target
-
- return [run_host_cmd_yesno "$ld" "$HOSTING_EMU $flags -o $target $objs $libs"]
-}
-
-# Link a program using ld, without including any libraries.
-#
-proc default_ld_simple_link { ld target objects } {
global host_triplet
global exec_output
# Define various symbols needed when not linking against all
# target libs.
-proc ld_simple_link_defsyms {} {
+proc ld_link_defsyms {} {
set flags "--defsym __stack_chk_fail=0"
if { ![ar_simple_create $ar $ld_options $binfile "$objfiles $ld_after"] } {
set failed 1
}
- } elseif { ![ld_simple_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
+ } elseif { ![ld_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
set maybe_failed 1
set ld_output "$exec_output"
}
global CXXFLAGS
global errcnt
global exec_output
+ global board_cflags
+
+ # When using GCC as the linker driver, we need to specify board cflags when
+ # linking because cflags may contain linker options. For example when
+ # linker options are included in GCC spec files then we need the -specs
+ # option.
+ if [board_info [target_info name] exists cflags] {
+ set board_cflags " [board_info [target_info name] cflags]"
+ } else {
+ set board_cflags ""
+ }
foreach testitem $ldtests {
foreach target $args {
# incorrect section attributes and the assembler will warn
# them.
if { [ string match "c++" $lang ] } {
- ld_compile "$CXX -c $CXXFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+ set cmd "$CXX -c $CXXFLAGS $cflags"
} else {
- ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+ set cmd "$CC -c $CFLAGS $cflags"
+ }
+ if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] {
+ set failed 1
+ break
}
}
+ if { $failed != 0 } {
+ unresolved $testname
+ continue
+ }
- # We have to use $CC to build PIE and shared library.
- if { [ string match "c" $lang ] } {
- set link_proc ld_simple_link
- set link_cmd $CC
- } elseif { [ string match "c++" $lang ] } {
- set link_proc ld_simple_link
+ if { [ string match "c++" $lang ] } {
+ set link_proc ld_link
set link_cmd $CXX
- } elseif { [ string match "-shared" $ld_options ] \
- || [ string match "-pie" $ld_options ] } {
- set link_proc ld_simple_link
- set link_cmd $CC
} else {
set link_proc ld_link
- set link_cmd $ld
+ set link_cmd $CC
}
if { $binfile eq "tmpdir/" } {
# compile only
pass $testname
continue;
- } elseif ![$link_proc $link_cmd $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
+ } elseif ![$link_proc $link_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld_options $objfiles"] {
set failed 1
}
}
}
- if { $failed == 0 } {
+ if { $failed == 0 && [isnative] } {
send_log "Running: $binfile > $binfile.out\n"
verbose "Running: $binfile > $binfile.out"
catch "exec $binfile > $binfile.out" exec_output
if { $failed != 0 } {
fail $testname
+ } elseif ![isnative] {
+ unsupported $testname
} else {
set errcnt 0
pass $testname
# incorrect section attributes and the assembler will warn
# them.
if { [ string match "c++" $lang ] } {
- ld_compile "$CXX -c $CXXFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+ set cmd "$CXX -c $CXXFLAGS $cflags"
} else {
- ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+ set cmd "$CC -c $CFLAGS $cflags"
}
+ if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] {
+ set failed 1
+ break
+ }
+ }
+ if { $failed != 0 } {
+ unresolved $testname
+ continue
}
# Clear error and warning counts.
set failed 1
}
} else {
- if { ![ld_simple_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
+ if { ![ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
set failed 1
}