summaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-sh
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@nildram.co.uk>2006-08-04 13:13:56 +0000
committerRichard Sandiford <rsandifo@nildram.co.uk>2006-08-04 13:13:56 +0000
commit12262680c8a02ebff9d9902cdb7566d77d43160e (patch)
treef5dc685a627728fc701c937bc56834637adb14ba /ld/testsuite/ld-sh
parent30c0e0248127b9e1760cf5e3331c368c25b3c859 (diff)
downloadbinutils-redhat-12262680c8a02ebff9d9902cdb7566d77d43160e.tar.gz
bfd/
2006-08-02 Richard Sandiford <richard@codesourcery.com> Kazu Hirata <kazu@codesourcery.com> Phil Edwards <phil@codesourcery.com> Nathan Sidwell <nathan@codesourcery.com> * config.bfd (sh-*-vxworks): Use bfd_elf32_shvxworks_vec and bfd_elf32_shlvxworks_vec. * configure.in (bfd_elf32_sh64_vec): Add elf-vxworks.lo. (bfd_elf32_sh64l_vec, bfd_elf32_sh64lin_vec): Likewise. (bfd_elf32_sh64blin_vec, bfd_elf32_sh64lnbsd_vec): Likewise. (bfd_elf32_sh64nbsd_vec, bfd_elf32_sh_vec): Likewise. (bfd_elf32_shblin_vec, bfd_elf32_shl_vec): Likewise. (bfd_elf32_shl_symbian_vec, bfd_elf32_shlin_vec): Likewise. (bfd_elf32_shlnbsd_vec, bfd_elf32_shnbsd_vec): Likewise. (bfd_elf32_shlvxworks_vec, bfd_elf32_shvxworks_vec): New stanzas. * configure: Regenerate. * Makefile.am: Regenerate dependencies. * Makefile.in: Regenerate. * elf-vxworks.c (elf_vxworks_gott_symbol_p): New function. (elf_vxworks_add_symbol_hook): Use it. (elf_vxworks_link_output_symbol_hook): Likewise. Use the hash table entry to check for weak undefined symbols and to obtain the original bfd. (elf_vxworks_emit_relocs): Use target_index instead of this_idx. * elf32-sh-relocs.h: New file, split from elf32-sh.c. (R_SH_DIR32): Use SH_PARTIAL32 for the partial_inplace field, SH_SRC_MASK32 for the src_mask field, and SH_ELF_RELOC for the special_function field. (R_SH_REL32): Use SH_PARTIAL32 and SH_SRC_MASK32 here too. (R_SH_REL32, R_SH_TLS_GD_32, R_SH_TLS_LD_32): Likewise. (R_SH_TLS_LDO_32, R_SH_TLS_IE_32, R_SH_TLS_LE_32): Likewise. (R_SH_TLS_DTPMOD32, R_SH_TLS_DTPOFF32, R_SH_TLS_TPOFF32): Likewise. (R_SH_GOT32, R_SH_PLT32, R_SH_COPY, R_SH_GLOB_DAT): Likewise. (R_SH_JMP_SLOT, R_SH_RELATIVE, R_SH_GOTOFF, R_SH_GOTPC): Likewise. (SH_PARTIAL32, SH_SRC_MASK32, SH_ELF_RELOC): Undefine at end of file. * elf32-sh.c: Include elf32-vxworks.h. (MINUS_ONE): Define. (sh_elf_howto_table): Include elf32-sh-relocs.h with SH_PARTIAL32 set to TRUE, SH_SRC_MASK32 set to 0xffffffff, and SH_ELF_RELOC set to sh_elf_reloc. (sh_vxworks_howto_table): New variable. Include elf32-sh-relocs.h with SH_PARTIAL32 set to FALSE, SH_SRC_MASK32 set to 0, and SH_ELF_RELOC set to bfd_elf_generic_reloc. (vxworks_object_p, get_howto_table): New functions. (sh_elf_reloc_type_lookup): Fix typo. Use get_howto_table. (sh_elf_info_to_howto): Use get_howto_table. (sh_elf_relax_section): Honor the partial_inplace field of the R_SH_DIR32 howto. (sh_elf_relax_delete_bytes): Likewise. (elf_sh_plt_info): New structure. (PLT_ENTRY_SIZE): Replace both definitions with... (ELF_PLT_ENTRY_SIZE): ...this new macro, with separate definitions for INCLUDE_SHMEDIA and !INCLUDE_SHMEDIA. (elf_sh_plt0_entry_be): Update sizes of both definitions accordingly. (elf_sh_plt0_entry_le): Likewise. (elf_sh_plt_entry_be, elf_sh_plt_entry_le): Likewise. (elf_sh_pic_plt_entry_be, elf_sh_pic_plt_entry_le): Likewise. (elf_sh_plts): New structure, with separate definitions for INCLUDE_SHMEDIA and !INCLUDE_SHMEDIA. (elf_sh_plt0_entry): Delete both definitions. (elf_sh_plt_entry, elf_sh_pic_plt_entry): Likewise. (elf_sh_sizeof_plt, elf_sh_plt_plt0_offset): Likewise. (elf_sh_plt_temp_offset, elf_sh_plt_symbol_offset): Likewise. (elf_sh_plt_reloc_offset): Likewise. (movi_shori_putval): Delete in favor of... (install_plt_field): ...this new function, with separate definitions for INCLUDE_SHMEDIA and !INCLUDE_SHMEDIA. (get_plt_info): New function, with separate definitions for INCLUDE_SHMEDIA and !INCLUDE_SHMEDIA. (elf_sh_plt0_linker_offset, elf_sh_plt0_gotid_offset): Delete. (VXWORKS_PLT_HEADER_SIZE, VXWORKS_PLT_ENTRY_SIZE): New macros. (vxworks_sh_plt0_entry_be, vxworks_sh_plt0_entry_le): New constants. (vxworks_sh_plt_entry_be, vxworks_sh_plt_entry_le): Likewise. (vxworks_sh_pic_plt_entry_be, vxworks_sh_pic_plt_entry_le): Likewise. (get_plt_index, get_plt_offset): New functions. (elf_sh_link_hash_table): Add srelplt2, plt_info and vxworks_p fields. (sh_elf_link_hash_table_create): Initialize them. (sh_elf_create_dynamic_sections): Call elf_vxworks_create_dynamic_sections for VxWorks. (allocate_dynrelocs): Use htab->plt_info to get the size of PLT entries. Allocate relocation entries in .rela.plt.unloaded if generating a VxWorks executable. (sh_elf_always_size_sections): New function. (sh_elf_size_dynamic_sections): Extend .rela.plt handling to .rela.plt.unloaded. (sh_elf_relocate_section): Use get_howto_table. Honor partial_inplace when calculating the addend for dynamic relocations. Use get_plt_index. (sh_elf_finish_dynamic_symbol): Use get_plt_index, install_plt_field and htab->plt_info. Fill in the bra .plt offset for VxWorks executables. Populate .rela.plt.unloaded. Do not make _GLOBAL_OFFSET_TABLE_ absolute on VxWorks. (sh_elf_finish_dynamic_sections): Use install_plt_field and htab->plt_info. Handle cases where there is no special PLT header. Populate the first relocation in .rela.plt.unloaded and fix up the remaining entries. (sh_elf_plt_sym_val): Use get_plt_info. (elf_backend_always_size_sections): Define. (TARGET_BIG_SYM, TARGET_BIG_NAME): Override for VxWorks. (TARGET_LITTLE_SYM, TARGET_BIG_SYM): Likewise. (elf32_bed, elf_backend_want_plt_sym): Likewise. (elf_symbol_leading_char, elf_backend_want_got_underscore): Likewise. (elf_backend_grok_prstatus, elf_backend_grok_psinfo): Likewise. (elf_backend_add_symbol_hook): Likewise. (elf_backend_link_output_symbol_hook): Likewise. (elf_backend_emit_relocs): Likewise. (elf_backend_final_write_processing): Likewise. (ELF_MAXPAGESIZE, ELF_COMMONPAGESIZE): Likewise. * targets.c (bfd_elf32_shlvxworks_vec): Declare. (bfd_elf32_shvxworks_vec): Likewise. (_bfd_target_vector): Include bfd_elf32_shlvxworks_vec and bfd_elf32_shvxworks_vec. gas/ * config/tc-sh.c (apply_full_field_fix): New function. (md_apply_fix): Use it instead of md_number_to_chars. Do not fill in fx_addnumber for BFD_RELOC_32_PLT_PCREL. (tc_gen_reloc): Use fx_addnumber rather than 0 as the default case. * config/tc-sh.h (TARGET_FORMAT): Override for TE_VXWORKS. ld/ 2006-08-02 Richard Sandiford <richard@codesourcery.com> Kazu Hirata <kazu@codesourcery.com> Phil Edwards <phil@codesourcery.com> * Makefile.am (ALL_EMULATIONS): Add eshelf_vxworks.o and eshlelf_vxworks.o. (eshelf_vxworks.c, eshlelf_vxworks.c): New rules. * Makefile.in: Regenerate. * configure.tgt (sh-*-vxworks): Use shelf_vxworks and shlelf_vxworks. * emulparams/shelf_vxworks.sh: New file. * emulparams/shlelf_vxworks.sh: Likewise. * emulparams/vxworks.sh (FINI): Prefix _etext with ${SYMPREFIX}. (OTHER_END_SYMBOLS): Likewise _ehdr. (DATA_END_SYMBOLS): Likewise _edata. * emultempl/vxworks.em (vxworks_after_open): Check whether output_bfd is indeed an ELF file before dealing with --force-dynamic. ld/testsuite/ * ld-sh/rd-sh.exp: Treat vxworks1-static.d specially. * ld-sh/sh-vxworks.exp: New file. * ld-sh/sh.exp: Extend sh-linux SIZEOF_HEADERS handling to sh-*-vxworks. * ld-sh/vxworks1-le.dd, ld-sh/vxworks1-lib-le.dd, * ld-sh/vxworks1-lib.dd, ld-sh/vxworks1-lib.nd, * ld-sh/vxworks1-lib.rd, ld-sh/vxworks1-lib.s, * ld-sh/vxworks1-static.d, ld-sh/vxworks1.dd, * ld-sh/vxworks1.ld, ld-sh/vxworks1.rd, ld-sh/vxworks1.s, * ld-sh/vxworks2-static.sd, ld-sh/vxworks2.s, * ld-sh/vxworks2.sd, ld-sh/vxworks3-le.dd, * ld-sh/vxworks3-lib-le.dd, ld-sh/vxworks3-lib.dd, * ld-sh/vxworks3-lib.s, ld-sh/vxworks3.dd, ld-sh/vxworks3.s, * ld-sh/vxworks4.d, ld-sh/vxworks4a.s, ld-sh/vxworks4b.s, * ld-sh/reloc1.s, ld-sh/reloc1.d: New tests.
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 926251baab..993247c51f 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 0000000000..b56cd7db8c
--- /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 0000000000..e57903491f
--- /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 0000000000..8435f7e127
--- /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 5d3d5d4de7..5fb6762d05 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 0000000000..d70c9af19b
--- /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 0000000000..1e3e6d6e26
--- /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 0000000000..fc9f3a6473
--- /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 0000000000..edf3db3994
--- /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 0000000000..4ad704425c
--- /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 0000000000..ff215645d6
--- /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 0000000000..dffc45b2ea
--- /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 0000000000..4f49005da8
--- /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 0000000000..ec5039d47e
--- /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 0000000000..ee50c74f68
--- /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 0000000000..3ae237348d
--- /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 0000000000..912755bc47
--- /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 0000000000..f680a58a3a
--- /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 0000000000..5ff87d3bef
--- /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 0000000000..3fc966c32d
--- /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 0000000000..011d20cd80
--- /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 0000000000..555be000be
--- /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 0000000000..6e10331653
--- /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 0000000000..fea019a2bb
--- /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 0000000000..86d631099d
--- /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 0000000000..c5721dd16f
--- /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 0000000000..2785567309
--- /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 0000000000..6c0228ad26
--- /dev/null
+++ b/ld/testsuite/ld-sh/vxworks4b.s
@@ -0,0 +1,4 @@
+ .data
+ .long . + 0xc
+ .long global + 0x1234
+ .long global + 0x1234 - .