SH gas configure and ld tests

Message ID 20200620124728.GE21885@bubble.grove.modra.org
State New
Headers show
Series
  • SH gas configure and ld tests
Related show

Commit Message

David Faust via Binutils June 20, 2020, 12:47 p.m.
All current SH gas targets use BFD.  sh-coff was incorrectly reported
as unsupported.

gas/
	* configure.tgt: Set bfd_gas for all SH targets.
ld/
	* testsuite/ld-sh/sh.exp: Don't run relax tests for non-ELF.
	Fail when ld_assemble fails.  Use elseif to reduce indentation.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/gas/configure.tgt b/gas/configure.tgt
index 6316593ebd..7c2d178ab5 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -386,7 +386,7 @@  case ${generic_target} in
   sh-*-uclinux* | sh[12]-*-uclinux*)	fmt=elf em=uclinux ;;
   sh-*-coff*)				fmt=coff ;;
   sh-*-nto*)				fmt=elf ;;
-  sh-*-pe*)				fmt=coff em=pe bfd_gas=yes endian=little ;;
+  sh-*-pe*)				fmt=coff em=pe endian=little ;;
   sh-*-kaos*)				fmt=elf ;;
   shle*-*-kaos*)			fmt=elf ;;
 
@@ -437,7 +437,8 @@  case ${generic_target} in
 esac
 
 case ${cpu_type} in
-  aarch64 | alpha | arm | csky | i386 | ia64 | microblaze | mips | ns32k | or1k | or1knd | pdp11 | ppc | riscv | sparc | z80 | z8k)
+  aarch64 | alpha | arm | csky | i386 | ia64 | microblaze | mips | ns32k | \
+  or1k | or1knd | pdp11 | ppc | riscv | sh | sparc | z80 | z8k)
     bfd_gas=yes
     ;;
 esac
diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp
index 8a15ceef3e..0096b5b706 100644
--- a/ld/testsuite/ld-sh/sh.exp
+++ b/ld/testsuite/ld-sh/sh.exp
@@ -30,98 +30,98 @@  if ![istarget sh*-*-*] {
 
 set testsimple "SH simple relaxing"
 
-if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
+if { ![is_elf_format] } {
     unresolved $testsimple
-} else { if ![ld_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
+} elseif { ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] } {
+    fail $testsimple
+} elseif { ![ld_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] } {
+    fail $testsimple
+} elseif { ![ld_nm $nm "" tmpdir/sh1] } {
+    fail $testsimple
+} elseif { ![info exists nm_output(bar)]
+	   || ![info exists nm_output(foo)]} {
+    send_log "bad output from nm\n"
+    verbose "bad output from nm"
+    fail $testsimple
+} elseif {$nm_output(bar) != $nm_output(foo) + 0xc} {
+    send_log "foo == $nm_output(foo)\n"
+    verbose "foo == $nm_output(foo)"
+    send_log "bar == $nm_output(bar)\n"
+    verbose "bar == $nm_output(bar)"
     fail $testsimple
 } else {
-    if ![ld_nm $nm "" tmpdir/sh1] {
-	unresolved $testsimple
-    } else {
-	if {![info exists nm_output(bar)] \
-	     || ![info exists nm_output(foo)]} {
-	    send_log "bad output from nm\n"
-	    verbose "bad output from nm"
-	    fail $testsimple
-	} else {
-	    if {$nm_output(bar) != $nm_output(foo) + 0xc} {
-		send_log "foo == $nm_output(foo)\n"
-		verbose "foo == $nm_output(foo)"
-		send_log "bar == $nm_output(bar)\n"
-		verbose "bar == $nm_output(bar)"
-		fail $testsimple
-	    } else {
-		pass $testsimple
-	    }
-	}
-    }
-} }
+    pass $testsimple
+}
 
 set testsrec "SH relaxing to S-records"
 
-if { [istarget sh*-linux-*] || [istarget sh-*-vxworks] } {
-    # On these "non-embedded" targets, the default ELF and srec start
-    # addresses will be SIZEOF_HEADERS bytes apart.  Ensure consistency
-    # by feeding the ELF start address to the srec link line.
-    catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
-    set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
-} else {
-    set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
-}
-if ![ld_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
-    fail $testsrec
+if { ![remote_file host exists tmpdir/sh1] } {
+    unresolved $testsrec
 } else {
-    # The file name is embedded in the S-records, so create both
-    # files with the same name.
-    catch "exec rm -f tmpdir/sh1.s2" exec_output
-    send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
-    verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2"
-    catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
-    if ![string match "" $exec_output] {
-	send_log "$exec_output\n"
-	verbose "$exec_output"
-	unresolved $testsrec
+    if { [istarget sh*-linux-*] || [istarget sh-*-vxworks] } {
+	# On these "non-embedded" targets, the default ELF and srec start
+	# addresses will be SIZEOF_HEADERS bytes apart.  Ensure consistency
+	# by feeding the ELF start address to the srec link line.
+	catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
+	set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
+    } else {
+	set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
+    }
+    if ![ld_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
+	fail $testsrec
     } else {
-	send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1\n"
-	verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
-	catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
+	# The file name is embedded in the S-records, so create both
+	# files with the same name.
+	catch "exec rm -f tmpdir/sh1.s2" exec_output
+	send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
+	verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2"
+	catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
 	if ![string match "" $exec_output] {
 	    send_log "$exec_output\n"
 	    verbose "$exec_output"
 	    unresolved $testsrec
 	} else {
-	    send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
-	    verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
-	    catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
-	    set exec_output [prune_warnings $exec_output]
+	    send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1\n"
+	    verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
+	    catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
 	    if ![string match "" $exec_output] {
 		send_log "$exec_output\n"
 		verbose "$exec_output"
-		fail $testsrec
+		unresolved $testsrec
 	    } else {
-		pass $testsrec
+		send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
+		verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
+		catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
+		set exec_output [prune_warnings $exec_output]
+		if ![string match "" $exec_output] {
+		    send_log "$exec_output\n"
+		    verbose "$exec_output"
+		    fail $testsrec
+		} else {
+		    pass $testsrec
+		}
 	    }
 	}
     }
 }
 
 set testadjsw8 "SH switch8 adjustment after relax"
-if ![ld_assemble $as "-relax $srcdir/$subdir/adjsw8.s" tmpdir/adjsw8.o] {
+if { ![is_elf_format] } {
     unresolved $testadjsw8
+} elseif { ![ld_assemble $as "-relax $srcdir/$subdir/adjsw8.s" tmpdir/adjsw8.o] } {
+    fail $testadjsw8
+} elseif { ![ld_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] } {
+    fail $testadjsw8
 } else {
-    if ![ld_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
-	fail $testadjsw8
+    send_log "exec $objdump -s tmpdir/adjsw8\n"
+    verbose "exec $objdump -s tmpdir/adjsw8"
+    catch "exec $objdump -s tmpdir/adjsw8" exec_output
+    if [string match "*04080c00*" $exec_output] {
+	pass $testadjsw8
     } else {
-	send_log "exec $objdump -s tmpdir/adjsw8\n"
-	verbose "exec $objdump -s tmpdir/adjsw8"
-	catch "exec $objdump -s tmpdir/adjsw8" exec_output
-	if [string match "*04080c00*" $exec_output] {
-	    pass $testadjsw8
-	} else {
-	    send_log "bad switch table\n"
-	    verbose "bad switch table"
-	    fail $testadjsw8
-	}
+	send_log "bad switch table\n"
+	verbose "bad switch table"
+	fail $testadjsw8
     }
 }