aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-sh
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/ld-sh')
-rw-r--r--ld/testsuite/ld-sh/rd-sh.exp6
-rw-r--r--ld/testsuite/ld-sh/reloc1.d10
-rw-r--r--ld/testsuite/ld-sh/reloc1.s2
-rw-r--r--ld/testsuite/ld-sh/sh-vxworks.exp42
-rw-r--r--ld/testsuite/ld-sh/sh.exp6
-rw-r--r--ld/testsuite/ld-sh/vxworks1-le.dd73
-rw-r--r--ld/testsuite/ld-sh/vxworks1-lib-le.dd76
-rw-r--r--ld/testsuite/ld-sh/vxworks1-lib.dd76
-rw-r--r--ld/testsuite/ld-sh/vxworks1-lib.nd9
-rw-r--r--ld/testsuite/ld-sh/vxworks1-lib.rd12
-rw-r--r--ld/testsuite/ld-sh/vxworks1-lib.s61
-rw-r--r--ld/testsuite/ld-sh/vxworks1-static.d4
-rw-r--r--ld/testsuite/ld-sh/vxworks1.dd73
-rw-r--r--ld/testsuite/ld-sh/vxworks1.ld30
-rw-r--r--ld/testsuite/ld-sh/vxworks1.rd19
-rw-r--r--ld/testsuite/ld-sh/vxworks1.s32
-rw-r--r--ld/testsuite/ld-sh/vxworks2-static.sd9
-rw-r--r--ld/testsuite/ld-sh/vxworks2.s6
-rw-r--r--ld/testsuite/ld-sh/vxworks2.sd13
-rw-r--r--ld/testsuite/ld-sh/vxworks3-le.dd34
-rw-r--r--ld/testsuite/ld-sh/vxworks3-lib-le.dd12
-rw-r--r--ld/testsuite/ld-sh/vxworks3-lib.dd12
-rw-r--r--ld/testsuite/ld-sh/vxworks3-lib.s12
-rw-r--r--ld/testsuite/ld-sh/vxworks3.dd34
-rw-r--r--ld/testsuite/ld-sh/vxworks3.s7
-rw-r--r--ld/testsuite/ld-sh/vxworks4.d11
-rw-r--r--ld/testsuite/ld-sh/vxworks4a.s2
-rw-r--r--ld/testsuite/ld-sh/vxworks4b.s4
28 files changed, 684 insertions, 3 deletions
diff --git a/ld/testsuite/ld-sh/rd-sh.exp b/ld/testsuite/ld-sh/rd-sh.exp
index 926251b..993247c 100644
--- a/ld/testsuite/ld-sh/rd-sh.exp
+++ b/ld/testsuite/ld-sh/rd-sh.exp
@@ -48,7 +48,11 @@ set rd_test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
foreach shtest $rd_test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $shtest]
- run_dump_test [file rootname $shtest]
+ # vxworks-static.d relies on files created by sh-vxworks.exp.
+ # We run it there instead of here.
+ if { [file tail $shtest] != "vxworks1-static.d" } {
+ run_dump_test [file rootname $shtest]
+ }
if [string match $srcdir/$subdir/*-dso.d $shtest] {
# Copy the output of the DSO-createing test to .so file.
# Notice that a DSO-creating test must preceed the tests
diff --git a/ld/testsuite/ld-sh/reloc1.d b/ld/testsuite/ld-sh/reloc1.d
new file mode 100644
index 0000000..b56cd7d
--- /dev/null
+++ b/ld/testsuite/ld-sh/reloc1.d
@@ -0,0 +1,10 @@
+#source: reloc1.s
+#as: -big
+#ld: -shared -EB --defsym foo=0x9000
+#objdump: -sj.data
+#target: sh*-*-elf sh-*-vxworks
+
+.*: file format elf32-sh.*
+
+Contents of section \.data:
+ .* 9123 .*
diff --git a/ld/testsuite/ld-sh/reloc1.s b/ld/testsuite/ld-sh/reloc1.s
new file mode 100644
index 0000000..e579034
--- /dev/null
+++ b/ld/testsuite/ld-sh/reloc1.s
@@ -0,0 +1,2 @@
+ .data
+ .word foo + 0x123
diff --git a/ld/testsuite/ld-sh/sh-vxworks.exp b/ld/testsuite/ld-sh/sh-vxworks.exp
new file mode 100644
index 0000000..8435f7e
--- /dev/null
+++ b/ld/testsuite/ld-sh/sh-vxworks.exp
@@ -0,0 +1,42 @@
+if { ![istarget "sh-*-vxworks"] } {
+ return
+}
+
+set endians { "--big" "-EB" "" "--little" "-EL" "-le" }
+
+foreach { gas_option ld_option suffix } $endians {
+ set vxworkstests {
+ {"VxWorks shared library test 1" "-shared -Tvxworks1.ld $ld_option"
+ "$gas_option" {vxworks1-lib.s}
+ {{readelf --relocs vxworks1-lib.rd}
+ {objdump -dr vxworks1-lib$suffix.dd}
+ {readelf --symbols vxworks1-lib.nd}}
+ "libvxworks1.so"}
+ {"VxWorks executable test 1 (dynamic)" \
+ "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic $ld_option"
+ "$gas_option" {vxworks1.s}
+ {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1$suffix.dd}}
+ "vxworks1"}
+ {"VxWorks executable test 2 (dynamic)" \
+ "-Tvxworks1.ld -q --force-dynamic $ld_option"
+ "$gas_option" {vxworks2.s}
+ {{readelf --segments vxworks2.sd}}
+ "vxworks2"}
+ {"VxWorks executable test 2 (static)"
+ "-Tvxworks1.ld $ld_option"
+ "$gas_option" {vxworks2.s}
+ {{readelf --segments vxworks2-static.sd}}
+ "vxworks2"}
+ {"VxWorks shared library test 3" "-shared -Tvxworks1.ld $ld_option"
+ "$gas_option" {vxworks3-lib.s}
+ {{objdump -dr vxworks3-lib$suffix.dd}}
+ "libvxworks3.so"}
+ {"VxWorks executable test 3 (dynamic)" \
+ "tmpdir/libvxworks3.so -Tvxworks1.ld -q --force-dynamic $ld_option"
+ "$gas_option" {vxworks3.s}
+ {{objdump -d vxworks3$suffix.dd}}
+ "vxworks3"}
+ }
+ run_ld_link_tests [subst $vxworkstests]
+}
+run_dump_test "vxworks1-static"
diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp
index 5d3d5d4..5fb6762 100644
--- a/ld/testsuite/ld-sh/sh.exp
+++ b/ld/testsuite/ld-sh/sh.exp
@@ -62,8 +62,10 @@ if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
set testsrec "SH relaxing to S-records"
-if [istarget sh*-linux-*] {
- # This target needs the explicit entry address.
+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 {
diff --git a/ld/testsuite/ld-sh/vxworks1-le.dd b/ld/testsuite/ld-sh/vxworks1-le.dd
new file mode 100644
index 0000000..d70c9af
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-le.dd
@@ -0,0 +1,73 @@
+
+.*: file format .*
+
+Disassembly of section \.plt:
+
+00080800 <_PROCEDURE_LINKAGE_TABLE_>:
+ 80800: 01 d1 mov\.l 80808 <_PROCEDURE_LINKAGE_TABLE_\+0x8>,r1 ! 0x81408
+ 80802: 12 61 mov\.l @r1,r1
+ 80804: 2b 41 jmp @r1
+ 80806: 09 00 nop
+ 80808: 08 14 .*
+ 80808: R_SH_DIR32 _GLOBAL_OFFSET_TABLE_\+0x8
+ 8080a: 08 00 .*
+
+0008080c <_sglobal@plt>:
+ 8080c: 01 d0 mov\.l 80814 <_sglobal@plt\+0x8>,r0 ! 0x8140c
+ 8080e: 02 60 mov\.l @r0,r0
+ 80810: 2b 40 jmp @r0
+ 80812: 09 00 nop
+ 80814: 0c 14 .*
+ 80814: R_SH_DIR32 _GLOBAL_OFFSET_TABLE_\+0xc
+ 80816: 08 00 .*
+ 80818: 01 d0 mov\.l 80820 <_sglobal@plt\+0x14>,r0 ! 0x0
+ 8081a: f1 af bra 80800 <_PROCEDURE_LINKAGE_TABLE_>
+ 8081c: 09 00 nop
+ 8081e: 09 00 nop
+ 80820: 00 00 .*
+ \.\.\.
+
+00080824 <_foo@plt>:
+ 80824: 01 d0 mov\.l 8082c <_foo@plt\+0x8>,r0 ! 0x81410
+ 80826: 02 60 mov\.l @r0,r0
+ 80828: 2b 40 jmp @r0
+ 8082a: 09 00 nop
+ 8082c: 10 14 .*
+ 8082c: R_SH_DIR32 _GLOBAL_OFFSET_TABLE_\+0x10
+ 8082e: 08 00 .*
+ 80830: 01 d0 mov\.l 80838 <_foo@plt\+0x14>,r0 ! 0xc
+ 80832: e5 af bra 80800 <_PROCEDURE_LINKAGE_TABLE_>
+ 80834: 09 00 nop
+ 80836: 09 00 nop
+ 80838: 0c 00 .*
+ \.\.\.
+Disassembly of section \.text:
+
+00080c00 <__start>:
+ 80c00: 22 4f sts\.l pr,@-r15
+ 80c02: 06 d0 mov\.l 80c1c <__start\+0x1c>,r0 ! 0x80824 <_foo@plt>
+ 80c04: 0b 40 jsr @r0
+ 80c06: 09 00 nop
+ 80c08: 05 d0 mov\.l 80c20 <__start\+0x20>,r0 ! 0x8080c <_sglobal@plt>
+ 80c0a: 0b 40 jsr @r0
+ 80c0c: 09 00 nop
+ 80c0e: 05 d0 mov\.l 80c24 <__start\+0x24>,r0 ! 0x80c28 <_sexternal>
+ 80c10: 0b 40 jsr @r0
+ 80c12: 09 00 nop
+ 80c14: 26 4f lds\.l @r15\+,pr
+ 80c16: 0b 00 rts
+ 80c18: 09 00 nop
+ 80c1a: 09 00 nop
+ 80c1c: 24 08 .*
+ 80c1c: R_SH_DIR32 \.plt\+0x24
+ 80c1e: 08 00 .*
+ 80c20: 0c 08 .*
+ 80c20: R_SH_DIR32 \.plt\+0xc
+ 80c22: 08 00 .*
+ 80c24: 28 0c .*
+ 80c24: R_SH_DIR32 _sexternal
+ 80c26: 08 00 .*
+
+00080c28 <_sexternal>:
+ 80c28: 0b 00 rts
+ 80c2a: 09 00 nop
diff --git a/ld/testsuite/ld-sh/vxworks1-lib-le.dd b/ld/testsuite/ld-sh/vxworks1-lib-le.dd
new file mode 100644
index 0000000..1e3e6d6
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-lib-le.dd
@@ -0,0 +1,76 @@
+
+.*: file format .*
+
+Disassembly of section \.plt:
+
+00080800 <_PROCEDURE_LINKAGE_TABLE_>:
+ 80800: 01 d0 mov\.l 80808 <_PROCEDURE_LINKAGE_TABLE_\+0x8>,r0 ! 0xc
+ 80802: ce 00 mov\.l @\(r0,r12\),r0
+ 80804: 2b 40 jmp @r0
+ 80806: 09 00 nop
+ 80808: 0c 00 .*
+ 8080a: 00 00 .*
+ 8080c: 01 d0 mov\.l 80814 <_sglobal@plt\+0x14>,r0 | 0x0
+ 8080e: c2 51 mov\.l @\(8,r12\),r1
+ 80810: 2b 41 jmp @r1
+ 80812: 09 00 nop
+ 80814: 00 00 .*
+ \.\.\.
+
+00080818 <_sexternal@plt>:
+ 80818: 01 d0 mov\.l 80820 <_sexternal@plt\+0x8>,r0 ! 0x10
+ 8081a: ce 00 mov\.l @\(r0,r12\),r0
+ 8081c: 2b 40 jmp @r0
+ 8081e: 09 00 nop
+ 80820: 10 00 .*
+ 80822: 00 00 .*
+ 80824: 01 d0 mov\.l 8082c <_sexternal@plt\+0x14>,r0 ! 0xc
+ 80826: c2 51 mov\.l @\(8,r12\),r1
+ 80828: 2b 41 jmp @r1
+ 8082a: 09 00 nop
+ 8082c: 0c 00 .*
+ \.\.\.
+Disassembly of section \.text:
+
+00080c00 <_foo>:
+ 80c00: c6 2f mov\.l r12,@-r15
+ 80c02: 22 4f sts\.l pr,@-r15
+ 80c04: 0a dc mov\.l 80c30 <_foo\+0x30>,r12 ! 0x0
+ 80c06: c2 6c mov\.l @r12,r12
+ 80c08: 0a d0 mov\.l 80c34 <_foo\+0x34>,r0 ! 0x0
+ 80c0a: ce 0c mov\.l @\(r0,r12\),r12
+ 80c0c: 0a d0 mov\.l 80c38 <_foo\+0x38>,r0 ! 0x14
+ 80c0e: ce 01 mov\.l @\(r0,r12\),r1
+ 80c10: 12 62 mov\.l @r1,r2
+ 80c12: 01 72 add #1,r2
+ 80c14: 22 21 mov\.l r2,@r1
+ 80c16: 09 d0 mov\.l 80c3c <_foo\+0x3c>,r0 ! 0x2c
+ 80c18: 03 00 bsrf r0
+ 80c1a: 09 00 nop
+ 80c1c: 08 d0 mov\.l 80c40 <_foo\+0x40>,r0 ! 0xfffffbde
+ 80c1e: 03 00 bsrf r0
+ 80c20: 09 00 nop
+ 80c22: 08 d0 mov\.l 80c44 <_foo\+0x44>,r0 ! 0xfffffbf0
+ 80c24: 03 00 bsrf r0
+ 80c26: 09 00 nop
+ 80c28: 26 4f lds\.l @r15\+,pr
+ 80c2a: 0b 00 rts
+ 80c2c: f6 6c mov\.l @r15\+,r12
+ 80c2e: 09 00 nop
+ ...
+ 80c38: 14 00 .*
+ 80c3a: 00 00 .*
+ 80c3c: 2c 00 .*
+ 80c3e: 00 00 .*
+ 80c40: de fb .*
+ 80c42: ff ff .*
+ 80c44: f0 fb .*
+ 80c46: ff ff .*
+
+00080c48 <_slocal>:
+ 80c48: 0b 00 rts
+ 80c4a: 09 00 nop
+
+00080c4c <_sglobal>:
+ 80c4c: 0b 00 rts
+ 80c4e: 09 00 nop
diff --git a/ld/testsuite/ld-sh/vxworks1-lib.dd b/ld/testsuite/ld-sh/vxworks1-lib.dd
new file mode 100644
index 0000000..fc9f3a64
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-lib.dd
@@ -0,0 +1,76 @@
+
+.*: file format .*
+
+Disassembly of section \.plt:
+
+00080800 <_PROCEDURE_LINKAGE_TABLE_>:
+ 80800: d0 01 mov\.l 80808 <_PROCEDURE_LINKAGE_TABLE_\+0x8>,r0 ! 0xc
+ 80802: 00 ce mov\.l @\(r0,r12\),r0
+ 80804: 40 2b jmp @r0
+ 80806: 00 09 nop
+ 80808: 00 00 .*
+ 8080a: 00 0c .*
+ 8080c: d0 01 mov\.l 80814 <_sglobal@plt\+0x14>,r0 | 0x0
+ 8080e: 51 c2 mov\.l @\(8,r12\),r1
+ 80810: 41 2b jmp @r1
+ 80812: 00 09 nop
+ 80814: 00 00 .*
+ \.\.\.
+
+00080818 <_sexternal@plt>:
+ 80818: d0 01 mov\.l 80820 <_sexternal@plt\+0x8>,r0 ! 0x10
+ 8081a: 00 ce mov\.l @\(r0,r12\),r0
+ 8081c: 40 2b jmp @r0
+ 8081e: 00 09 nop
+ 80820: 00 00 .*
+ 80822: 00 10 .*
+ 80824: d0 01 mov\.l 8082c <_sexternal@plt\+0x14>,r0 ! 0xc
+ 80826: 51 c2 mov\.l @\(8,r12\),r1
+ 80828: 41 2b jmp @r1
+ 8082a: 00 09 nop
+ 8082c: 00 00 .*
+ 8082e: 00 0c .*
+Disassembly of section \.text:
+
+00080c00 <_foo>:
+ 80c00: 2f c6 mov\.l r12,@-r15
+ 80c02: 4f 22 sts\.l pr,@-r15
+ 80c04: dc 0a mov\.l 80c30 <_foo\+0x30>,r12 ! 0x0
+ 80c06: 6c c2 mov\.l @r12,r12
+ 80c08: d0 0a mov\.l 80c34 <_foo\+0x34>,r0 ! 0x0
+ 80c0a: 0c ce mov\.l @\(r0,r12\),r12
+ 80c0c: d0 0a mov\.l 80c38 <_foo\+0x38>,r0 ! 0x14
+ 80c0e: 01 ce mov\.l @\(r0,r12\),r1
+ 80c10: 62 12 mov\.l @r1,r2
+ 80c12: 72 01 add #1,r2
+ 80c14: 21 22 mov\.l r2,@r1
+ 80c16: d0 09 mov\.l 80c3c <_foo\+0x3c>,r0 ! 0x2c
+ 80c18: 00 03 bsrf r0
+ 80c1a: 00 09 nop
+ 80c1c: d0 08 mov\.l 80c40 <_foo\+0x40>,r0 ! 0xfffffbde
+ 80c1e: 00 03 bsrf r0
+ 80c20: 00 09 nop
+ 80c22: d0 08 mov\.l 80c44 <_foo\+0x44>,r0 ! 0xfffffbf0
+ 80c24: 00 03 bsrf r0
+ 80c26: 00 09 nop
+ 80c28: 4f 26 lds\.l @r15\+,pr
+ 80c2a: 00 0b rts
+ 80c2c: 6c f6 mov\.l @r15\+,r12
+ 80c2e: 00 09 nop
+ ...
+ 80c38: 00 00 .*
+ 80c3a: 00 14 .*
+ 80c3c: 00 00 .*
+ 80c3e: 00 2c .*
+ 80c40: ff ff .*
+ 80c42: fb de .*
+ 80c44: ff ff .*
+ 80c46: fb f0 .*
+
+00080c48 <_slocal>:
+ 80c48: 00 0b rts
+ 80c4a: 00 09 nop
+
+00080c4c <_sglobal>:
+ 80c4c: 00 0b rts
+ 80c4e: 00 09 nop
diff --git a/ld/testsuite/ld-sh/vxworks1-lib.nd b/ld/testsuite/ld-sh/vxworks1-lib.nd
new file mode 100644
index 0000000..edf3db3
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-lib.nd
@@ -0,0 +1,9 @@
+#...
+Symbol table '\.dynsym' .*:
+#...
+.*: 00081400 * 0 * OBJECT * GLOBAL * DEFAULT * [0-9]+ _GLOBAL_OFFSET_TABLE_
+#...
+Symbol table '\.symtab' .*:
+#...
+.*: 00081400 * 0 * OBJECT * GLOBAL * DEFAULT * [0-9]+ _GLOBAL_OFFSET_TABLE_
+#pass
diff --git a/ld/testsuite/ld-sh/vxworks1-lib.rd b/ld/testsuite/ld-sh/vxworks1-lib.rd
new file mode 100644
index 0000000..4ad7044
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-lib.rd
@@ -0,0 +1,12 @@
+
+Relocation section '\.rela\.plt' at offset .* contains 2 entries:
+ Offset Info Type Sym\.Value Sym\. Name \+ Addend
+0008140c .*a4 R_SH_JMP_SLOT 00080c4c _sglobal \+ 0
+00081410 .*a4 R_SH_JMP_SLOT 00000000 _sexternal \+ 0
+
+Relocation section '\.rela\.dyn' at offset .* contains 4 entries:
+ Offset Info Type Sym\.Value Sym\. Name \+ Addend
+00081c00 000000a5 R_SH_RELATIVE * 00080c48
+00080c30 .*01 R_SH_DIR32 00000000 ___GOTT_BASE__ \+ 0
+00080c34 .*01 R_SH_DIR32 00000000 ___GOTT_INDEX__ \+ 0
+00081414 .*a3 R_SH_GLOB_DAT 00081800 x \+ 0
diff --git a/ld/testsuite/ld-sh/vxworks1-lib.s b/ld/testsuite/ld-sh/vxworks1-lib.s
new file mode 100644
index 0000000..ff21564
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-lib.s
@@ -0,0 +1,61 @@
+ .text
+ .globl _foo
+ .type _foo, %function
+_foo:
+ mov.l r12,@-r15
+ sts.l pr,@-r15
+ mov.l 1f,r12
+ mov.l @r12,r12
+ mov.l 2f,r0
+ mov.l @(r0,r12),r12
+
+ mov.l 3f,r0
+ mov.l @(r0,r12),r1
+ mov.l @r1,r2
+ add #1,r2
+ mov.l r2,@r1
+
+ mov.l 4f,r0
+ bsrf r0
+ nop
+.Lb4:
+
+ mov.l 5f,r0
+ bsrf r0
+ nop
+.Lb5:
+
+ mov.l 6f,r0
+ bsrf r0
+ nop
+.Lb6:
+
+ lds.l @r15+,pr
+ rts
+ mov.l @r15+,r12
+ .align 2
+1: .long ___GOTT_BASE__
+2: .long ___GOTT_INDEX__
+3: .long x@GOT
+4: .long _slocal - .Lb4
+5: .long _sglobal@PLT - (.Lb5 - .)
+6: .long _sexternal@PLT - (.Lb6 - .)
+ .size _foo, .-_foo
+
+ .type _slocal, %function
+_slocal:
+ rts
+ nop
+ .size _slocal, .-_slocal
+
+ .globl _sglobal
+ .type _sglobal, %function
+_sglobal:
+ rts
+ nop
+ .size _sglobal, .-_sglobal
+
+ .data
+ .4byte _slocal
+
+ .comm x,4,4
diff --git a/ld/testsuite/ld-sh/vxworks1-static.d b/ld/testsuite/ld-sh/vxworks1-static.d
new file mode 100644
index 0000000..dffc45b
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1-static.d
@@ -0,0 +1,4 @@
+#name: VxWorks executable test 1 (static)
+#source: vxworks1.s
+#ld: tmpdir/libvxworks1.so -Tvxworks1.ld -EL
+#error: Dynamic sections created in non-dynamic link
diff --git a/ld/testsuite/ld-sh/vxworks1.dd b/ld/testsuite/ld-sh/vxworks1.dd
new file mode 100644
index 0000000..4f49005d
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1.dd
@@ -0,0 +1,73 @@
+
+.*: file format .*
+
+Disassembly of section \.plt:
+
+00080800 <_PROCEDURE_LINKAGE_TABLE_>:
+ 80800: d1 01 mov\.l 80808 <_PROCEDURE_LINKAGE_TABLE_\+0x8>,r1 ! 0x81408
+ 80802: 61 12 mov\.l @r1,r1
+ 80804: 41 2b jmp @r1
+ 80806: 00 09 nop
+ 80808: 00 08 .*
+ 80808: R_SH_DIR32 _GLOBAL_OFFSET_TABLE_\+0x8
+ 8080a: 14 08 .*
+
+0008080c <_sglobal@plt>:
+ 8080c: d0 01 mov\.l 80814 <_sglobal@plt\+0x8>,r0 ! 0x8140c
+ 8080e: 60 02 mov\.l @r0,r0
+ 80810: 40 2b jmp @r0
+ 80812: 00 09 nop
+ 80814: 00 08 .*
+ 80814: R_SH_DIR32 _GLOBAL_OFFSET_TABLE_\+0xc
+ 80816: 14 0c .*
+ 80818: d0 01 mov\.l 80820 <_sglobal@plt\+0x14>,r0 ! 0x0
+ 8081a: af f1 bra 80800 <_PROCEDURE_LINKAGE_TABLE_>
+ 8081c: 00 09 nop
+ 8081e: 00 09 nop
+ 80820: 00 00 .*
+ \.\.\.
+
+00080824 <_foo@plt>:
+ 80824: d0 01 mov\.l 8082c <_foo@plt\+0x8>,r0 ! 0x81410
+ 80826: 60 02 mov\.l @r0,r0
+ 80828: 40 2b jmp @r0
+ 8082a: 00 09 nop
+ 8082c: 00 08 .*
+ 8082c: R_SH_DIR32 _GLOBAL_OFFSET_TABLE_\+0x10
+ 8082e: 14 10 .*
+ 80830: d0 01 mov\.l 80838 <_foo@plt\+0x14>,r0 ! 0xc
+ 80832: af e5 bra 80800 <_PROCEDURE_LINKAGE_TABLE_>
+ 80834: 00 09 nop
+ 80836: 00 09 nop
+ 80838: 00 00 .*
+ 8083a: 00 0c .*
+Disassembly of section \.text:
+
+00080c00 <__start>:
+ 80c00: 4f 22 sts\.l pr,@-r15
+ 80c02: d0 06 mov\.l 80c1c <__start\+0x1c>,r0 ! 0x80824 <_foo@plt>
+ 80c04: 40 0b jsr @r0
+ 80c06: 00 09 nop
+ 80c08: d0 05 mov\.l 80c20 <__start\+0x20>,r0 ! 0x8080c <_sglobal@plt>
+ 80c0a: 40 0b jsr @r0
+ 80c0c: 00 09 nop
+ 80c0e: d0 05 mov\.l 80c24 <__start\+0x24>,r0 ! 0x80c28 <_sexternal>
+ 80c10: 40 0b jsr @r0
+ 80c12: 00 09 nop
+ 80c14: 4f 26 lds\.l @r15\+,pr
+ 80c16: 00 0b rts
+ 80c18: 00 09 nop
+ 80c1a: 00 09 nop
+ 80c1c: 00 08 .*
+ 80c1c: R_SH_DIR32 \.plt\+0x24
+ 80c1e: 08 24 .*
+ 80c20: 00 08 .*
+ 80c20: R_SH_DIR32 \.plt\+0xc
+ 80c22: 08 0c .*
+ 80c24: 00 08 .*
+ 80c24: R_SH_DIR32 _sexternal
+ 80c26: 0c 28 .*
+
+00080c28 <_sexternal>:
+ 80c28: 00 0b rts
+ 80c2a: 00 09 nop
diff --git a/ld/testsuite/ld-sh/vxworks1.ld b/ld/testsuite/ld-sh/vxworks1.ld
new file mode 100644
index 0000000..ec5039d
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1.ld
@@ -0,0 +1,30 @@
+SECTIONS
+{
+ . = 0x80000;
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+
+ . = ALIGN (0x400);
+ .rela.dyn : { *(.rela.dyn) }
+ .rela.plt : { *(.rela.plt) }
+
+ . = ALIGN (0x400);
+ .plt : { *(.plt) }
+
+ . = ALIGN (0x400);
+ .text : { *(.text) }
+
+ . = ALIGN (0x1000);
+ .dynamic : { *(.dynamic) }
+
+ . = ALIGN (0x400);
+ .got : { *(.got.plt) *(.got) }
+
+ . = ALIGN (0x400);
+ .bss : { *(.bss) *(.dynbss) }
+
+ . = ALIGN (0x400);
+ .data : { *(.data) }
+}
diff --git a/ld/testsuite/ld-sh/vxworks1.rd b/ld/testsuite/ld-sh/vxworks1.rd
new file mode 100644
index 0000000..ee50c74
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1.rd
@@ -0,0 +1,19 @@
+
+Relocation section '\.rela\.plt' at offset .* contains 2 entries:
+ Offset Info Type Sym\.Value Sym\. Name \+ Addend
+0008140c .*a4 R_SH_JMP_SLOT 0008080c _sglobal \+ 0
+00081410 .*a4 R_SH_JMP_SLOT 00080824 _foo \+ 0
+
+Relocation section '\.rela\.text' at offset .* contains 3 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+00080c1c .*01 R_SH_DIR32 00080800 \.plt \+ 24
+00080c20 .*01 R_SH_DIR32 00080800 \.plt \+ c
+00080c24 .*01 R_SH_DIR32 00080c28 _sexternal \+ 0
+
+Relocation section '\.rela\.plt\.unloaded' at offset .* contains 5 entries:
+ Offset Info Type Sym\.Value Sym\. Name \+ Addend
+00080808 .*01 R_SH_DIR32 00081400 _GLOBAL_OFFSET_TABLE_ \+ 8
+00080814 .*01 R_SH_DIR32 00081400 _GLOBAL_OFFSET_TABLE_ \+ c
+0008140c .*01 R_SH_DIR32 00080800 _PROCEDURE_LINKAGE_TAB.* \+ 0
+0008082c .*01 R_SH_DIR32 00081400 _GLOBAL_OFFSET_TABLE_ \+ 10
+00081410 .*01 R_SH_DIR32 00080800 _PROCEDURE_LINKAGE_TAB.* \+ 0
diff --git a/ld/testsuite/ld-sh/vxworks1.s b/ld/testsuite/ld-sh/vxworks1.s
new file mode 100644
index 0000000..3ae2373
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks1.s
@@ -0,0 +1,32 @@
+ .text
+ .globl __start
+ .type __start, %function
+__start:
+ sts.l pr,@-r15
+ mov.l 1f,r0
+ jsr @r0
+ nop
+
+ mov.l 2f,r0
+ jsr @r0
+ nop
+
+ mov.l 3f,r0
+ jsr @r0
+ nop
+
+ lds.l @r15+,pr
+ rts
+ nop
+ .align 2
+1: .long _foo
+2: .long _sglobal
+3: .long _sexternal
+ .size __start, .-__start
+
+ .globl _sexternal
+ .type _sexternal, %function
+_sexternal:
+ rts
+ nop
+ .size _sexternal, .-_sexternal
diff --git a/ld/testsuite/ld-sh/vxworks2-static.sd b/ld/testsuite/ld-sh/vxworks2-static.sd
new file mode 100644
index 0000000..912755b
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks2-static.sd
@@ -0,0 +1,9 @@
+#...
+Elf file type is EXEC \(Executable file\)
+Entry point 0x80000
+#...
+Program Headers:
+ Type .*
+ LOAD .* 0x00080000 0x00080000 .* R E 0x1000
+
+#...
diff --git a/ld/testsuite/ld-sh/vxworks2.s b/ld/testsuite/ld-sh/vxworks2.s
new file mode 100644
index 0000000..f680a58
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks2.s
@@ -0,0 +1,6 @@
+ .globl __start
+ .type __start, %function
+__start:
+ rts
+ nop
+ .end __start
diff --git a/ld/testsuite/ld-sh/vxworks2.sd b/ld/testsuite/ld-sh/vxworks2.sd
new file mode 100644
index 0000000..5ff87d3
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks2.sd
@@ -0,0 +1,13 @@
+#...
+Elf file type is EXEC \(Executable file\)
+Entry point 0x80400
+#...
+Program Headers:
+ Type .*
+ PHDR .*
+#...
+ LOAD .* 0x00080000 0x00080000 .* R E 0x1000
+ LOAD .* 0x00081000 0x00081000 .* RW 0x1000
+ DYNAMIC .*
+
+#...
diff --git a/ld/testsuite/ld-sh/vxworks3-le.dd b/ld/testsuite/ld-sh/vxworks3-le.dd
new file mode 100644
index 0000000..3fc966c
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks3-le.dd
@@ -0,0 +1,34 @@
+
+.*: file format .*
+
+Disassembly of section \.plt:
+
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0x0
+.*: f1 af bra .* <_PROCEDURE_LINKAGE_TABLE_>
+.*: 09 00 nop
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0x7ec
+.*: 05 a8 bra .* <_PROCEDURE_LINKAGE_TABLE_>
+.*: 09 00 nop
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0x7f8
+.*: f2 af bra .*
+.*: 09 00 nop
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0xfe4
+.*: 06 a8 bra .*
+.*: 09 00 nop
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0xff0
+.*: f2 af bra .*
+.*: 09 00 nop
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0x17dc
+.*: 06 a8 bra .*
+.*: 09 00 nop
+#...
+.*: 01 d0 mov\.l .*,r0 ! 0x17e8
+.*: f2 af bra .*
+.*: 09 00 nop
+#pass
diff --git a/ld/testsuite/ld-sh/vxworks3-lib-le.dd b/ld/testsuite/ld-sh/vxworks3-lib-le.dd
new file mode 100644
index 0000000..011d20c
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks3-lib-le.dd
@@ -0,0 +1,12 @@
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+.* <foo0>:
+.*: 0b 00 rts
+.*: 09 00 nop
+#...
+.* <foo510>:
+.*: 0b 00 rts
+.*: 09 00 nop
diff --git a/ld/testsuite/ld-sh/vxworks3-lib.dd b/ld/testsuite/ld-sh/vxworks3-lib.dd
new file mode 100644
index 0000000..555be00
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks3-lib.dd
@@ -0,0 +1,12 @@
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+.* <foo0>:
+.*: 00 0b rts
+.*: 00 09 nop
+#...
+.* <foo510>:
+.*: 00 0b rts
+.*: 00 09 nop
diff --git a/ld/testsuite/ld-sh/vxworks3-lib.s b/ld/testsuite/ld-sh/vxworks3-lib.s
new file mode 100644
index 0000000..6e10331
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks3-lib.s
@@ -0,0 +1,12 @@
+ .macro entry
+ .globl foo\@
+ .size foo\@,4
+ .type foo\@,@function
+foo\@:
+ rts
+ nop
+ .endm
+
+ .rept 511
+ entry
+ .endr
diff --git a/ld/testsuite/ld-sh/vxworks3.dd b/ld/testsuite/ld-sh/vxworks3.dd
new file mode 100644
index 0000000..fea019a
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks3.dd
@@ -0,0 +1,34 @@
+
+.*: file format .*
+
+Disassembly of section \.plt:
+
+#...
+.*: d0 01 mov\.l .*,r0 ! 0x0
+.*: af f1 bra .* <_PROCEDURE_LINKAGE_TABLE_>
+.*: 00 09 nop
+#...
+.*: d0 01 mov\.l .*,r0 ! 0x7ec
+.*: a8 05 bra .* <_PROCEDURE_LINKAGE_TABLE_>
+.*: 00 09 nop
+#...
+.*: d0 01 mov\.l .*,r0 ! 0x7f8
+.*: af f2 bra .*
+.*: 00 09 nop
+#...
+.*: d0 01 mov\.l .*,r0 ! 0xfe4
+.*: a8 06 bra .*
+.*: 00 09 nop
+#...
+.*: d0 01 mov\.l .*,r0 ! 0xff0
+.*: af f2 bra .*
+.*: 00 09 nop
+#...
+.*: d0 01 mov\.l .*,r0 ! 0x17dc
+.*: a8 06 bra .*
+.*: 00 09 nop
+#...
+.*: d0 01 mov\.l .*,r0 ! 0x17e8
+.*: af f2 bra .*
+.*: 00 09 nop
+#pass
diff --git a/ld/testsuite/ld-sh/vxworks3.s b/ld/testsuite/ld-sh/vxworks3.s
new file mode 100644
index 0000000..86d6310
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks3.s
@@ -0,0 +1,7 @@
+ .macro entry
+ .long foo\@
+ .endm
+
+ .rept 511
+ entry
+ .endr
diff --git a/ld/testsuite/ld-sh/vxworks4.d b/ld/testsuite/ld-sh/vxworks4.d
new file mode 100644
index 0000000..c5721dd
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks4.d
@@ -0,0 +1,11 @@
+#source: vxworks4a.s
+#source: vxworks4b.s
+#ld: -shared -Tvxworks1.ld
+#target: sh-*-vxworks
+#readelf: --relocs
+
+Relocation section '\.rela\.dyn' at offset .* contains 3 entries:
+ Offset Info Type Sym\.Value Sym\. Name \+ Addend
+00081810 000000a5 R_SH_RELATIVE 0008181c
+00081814 .*01 R_SH_DIR32 00000000 global \+ 1234
+00081818 .*02 R_SH_REL32 00000000 global \+ 1234
diff --git a/ld/testsuite/ld-sh/vxworks4a.s b/ld/testsuite/ld-sh/vxworks4a.s
new file mode 100644
index 0000000..2785567
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks4a.s
@@ -0,0 +1,2 @@
+ .data
+ .fill 0x10
diff --git a/ld/testsuite/ld-sh/vxworks4b.s b/ld/testsuite/ld-sh/vxworks4b.s
new file mode 100644
index 0000000..6c0228a
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks4b.s
@@ -0,0 +1,4 @@
+ .data
+ .long . + 0xc
+ .long global + 0x1234
+ .long global + 0x1234 - .