# Test linking directly to S-records.
# By Ian Lance Taylor, Cygnus Support.
-# Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2011
-# Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
# Tell the ELF linker to not do anything clever with .eh_frame,
# not to put anything in small data, and define various symbols.
- set flags "--traditional-format -G 0 "
- append flags [ld_simple_link_defsyms]
+ set flags "--traditional-format -G 0 -e 0 "
+ append flags [ld_link_defsyms]
# If the linker script uses SIZEOF_HEADERS, use a -Ttext argument
# to force both the normal link and the S-record link to be put in
set flags "$flags -Ttext 0x1000"
}
- if [istarget sh64*-*-elf] {
- # This is what gcc passes to ld by default.
- set flags "$flags -mshelf32"
- # SH64 targets cannot convert format in the linker
- # using the -oformat command line switch.
- setup_xfail "sh64*-*-*"
+ # ARM targets cannot convert format in the linker
+ # using the --oformat command line switch
+ if {[istarget aarch64*-*-*] || \
+ [istarget arm*-*-*]} {
+ setup_xfail "aarch64-*-*"
+ setup_xfail "aarch64_be-*-*"
+ setup_xfail "arm*-*-*"
}
- if {[istarget arm*-*-*]} {
- # ARM targets cannot convert format in the linker
- # using the --oformat command line switch
- setup_xfail "arm*-*-*"
+ # The AVR target does not correctly process
+ # relocs when output format is not ELF.
+ if [istarget avr-*-*] {
+ setup_xfail "avr-*-*"
+ }
+
+ # Epiphany needs some help too
+ if [istarget epiphany*-*-*] {
+ set flags "$flags --defsym _start=00000060"
+ setup_xfail "epiphany*-*-*"
+ }
+
+ if [istarget m681*-*-*] {
+ set flags "$flags --defsym _start=0xc000"
+ setup_xfail "m681*-*-*"
+ }
+
+ if [istarget m68hc1*-*-*] {
+ set flags "$flags --defsym _start=0xc000"
+ setup_xfail "m68hc1*-*-*"
+ }
+
+ if [istarget m9s12x*-*-*] {
+ set flags "$flags --defsym _start=0xc000"
+ setup_xfail "m9s12x*-*-*"
+ }
+
+ # MSP430 targets always relax.
+ if [istarget msp430*-*-*] {
+ setup_xfail "msp430*-*-*"
+ }
+
+ # The RISC-V target does not correctly process
+ # relocs when output format is not ELF.
+ if [istarget riscv*-*-*] {
+ setup_xfail "riscv*-*-*"
}
# V850 targets need libgcc.a
set flags "$flags -no-relax"
}
- if [istarget powerpc64*-*-*] {
- set flags "$flags --no-toc-optimize"
+ # PRU ELF target relaxes by default; S-Record linker does not
+ if [istarget pru*-*-*] {
+ set flags "$flags -no-relax"
}
- if { ![ld_simple_link $ld tmpdir/sr1 "$flags $objs"] \
- || ![ld_simple_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } {
+ if { ![ld_link $ld tmpdir/sr1 "$flags $objs"] \
+ || ![ld_link $ld tmpdir/sr2.sr "$flags --oformat srec $objs"] } {
fail $test
return
}
# directly to the S-record format, and require that the two files
# contain the same data.
-if { ![is_remote host] && [which $CC] == 0 } {
+if { ![check_compiler_available] } {
untested $test1
untested $test2
return
}
+# Pass -fplt to CC and CXX since -fno-plt doesn't work with S-records
+# tests. Also add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if PIE doesn't work
+# with S-records. Also add $NOCF_PROTECTION_CFLAGS for S-records.
+# Also add $NOSANITIZE_CFLAGS for S-records.
+set old_CC "$CC"
+set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set old_CXX "$CXX"
+set old_CXXFLAGS "$CXXFLAGS"
+set CXXFLAGS "$CXXFLAGS $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+
+# S-records can't handle .note.gnu.property sections.
+if { [is_elf_format] \
+ && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
+ set CC "$CC -Wa,-mx86-used-note=no"
+ set CXX "$CXX -Wa,-mx86-used-note=no"
+}
+
if { ![ld_compile $CC $srcdir/$subdir/sr1.c tmpdir/sr1.o] \
|| ![ld_compile $CC $srcdir/$subdir/sr2.c tmpdir/sr2.o] } {
unresolved $test1
unresolved $test2
+ set CC "$old_CC"
+ set CXX "$old_CXX"
+ set CXXFLAGS "$old_CXXFLAGS"
return
}
# The S-record linker doesn't do the magic TOC handling that XCOFF
# linkers do.
-setup_xfail "*-*-aix*" "*-*-xcoff*"
+if [is_xcoff_format] {
+ setup_xfail *-*-*
+}
+
+# The S-record linker is not supported for ARC.
+setup_xfail "arc*-*-*"
# The S-record linker doesn't build ARM/Thumb stubs.
setup_xfail "arm-*-coff"
# generate the format if need be).
setup_xfail "tile*-*-*"
+# The S-record linker is not supported for C-SKY.
+setup_xfail "csky*-*-*"
+
+# The S-record linker is not supported for eBPF.
+setup_xfail "bpf-*-*"
+
run_srec_test $test1 "tmpdir/sr1.o tmpdir/sr2.o"
# Now try linking a C++ program with global constructors and
if { ![is_remote host] && [which $CXX] == 0 } {
untested $test2
+ set CC "$old_CC"
+ set CXX "$old_CXX"
+ set CXXFLAGS "$old_CXXFLAGS"
return
}
if ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/sr3.cc tmpdir/sr3.o] {
unresolved $test2
+ set CC "$old_CC"
+ set CXX "$old_CXX"
+ set CXXFLAGS "$old_CXXFLAGS"
return
}
# See above.
setup_xfail "i*86-*-aout*"
setup_xfail "mips*-*-irix5*" "mips*-*-irix6*" "mips*-*-linux*"
-setup_xfail "*-*-aix*" "*-*-xcoff*"
+if [is_xcoff_format] {
+ setup_xfail *-*-*
+}
+setup_xfail "arc*-*-*"
setup_xfail "arm*-*-*"
setup_xfail "v850*-*-elf"
setup_xfail "alpha*-*-elf*" "alpha*-*-linux-*" "alpha*-*-gnu*"
setup_xfail "score-*-*"
setup_xfail "bfin-*-linux-uclibc"
setup_xfail "tile*-*-*"
+setup_xfail "csky*-*-*"
+setup_xfail "bpf-*-*"
run_srec_test $test2 "tmpdir/sr3.o"
+
+set CC "$old_CC"
+set CXX "$old_CXX"
+set CXXFLAGS "$old_CXXFLAGS"