aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-05-03 20:43:10 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-05-03 20:47:40 +0100
commit8507b6e79772ffeb83a0142d12a63e02dcc44562 (patch)
tree0952e6c10d5abbb11afa9cb6cee1903b44ec30ba /ld
parent90cef2edd256c48d2ff9a03d4a6c1bcb575db07c (diff)
downloadgdb-8507b6e79772ffeb83a0142d12a63e02dcc44562.zip
gdb-8507b6e79772ffeb83a0142d12a63e02dcc44562.tar.gz
gdb-8507b6e79772ffeb83a0142d12a63e02dcc44562.tar.bz2
MIPS16/GAS: Relax 32-bit non-PIC PC-relative synthetic instructions
Implement the relaxation of MIPS16 PC-relative synthetic LA, DLA, LW and LD instructions to an equivalent sequence of instructions produced where the address operand requested is out of range, absolute or requires linker relocation, for ABIs that use 32-bit addressing and non-PIC code. The sequence generated uses the register specified for the destination operand as a temporary and begins with LI to load the high 16-bit part of the address, then continues with SLL by 16 bits to move that part into place and finally completes with a suitable operation corresponding to the synthetic instruction used, one of: 2-argument ADDIU, 2-argument DADDIU, absolute LW, and absolute LD respectively, providing the low 16-bit part of the address. All instructions use the extended encoding. As a special exception accept absolute addresses for relaxation even in PIC code. For example: la $2, 0x12345678 produces code as: li $2, 0x1234 sll $2, $2, 16 addiu $2, 0x5678 would. Where linker relocation is required emit an R_MIPS16_HI16 relocation on the initial LI instruction and an R_MIPS16_LO16 relocation on the final operation. For example (where `foo' is not local): lw $3, foo produces code as: li $3, %hi(foo) sll $3, $3, 16 lw $3, %lo(foo)($3) would. Emit assembly warnings as appropriate where this new relaxation triggers in the `nomacro' mode or for an instruction manually placed in a branch delay slot in the `noreorder' mode. Refrain from relaxation where an explicit instruction size suffix has been used and in the `noautoextend' mode. gas/ * config/tc-mips.c (RELAX_MIPS16_ENCODE): Add `pic', `sym32' and `nomacro' flags. (RELAX_MIPS16_PIC, RELAX_MIPS16_SYM32, RELAX_MIPS16_NOMACRO): New macros. (RELAX_MIPS16_USER_SMALL, RELAX_MIPS16_USER_EXT) (RELAX_MIPS16_DSLOT, RELAX_MIPS16_JAL_DSLOT) (RELAX_MIPS16_EXTENDED, RELAX_MIPS16_MARK_EXTENDED) (RELAX_MIPS16_CLEAR_EXTENDED, RELAX_MIPS16_ALWAYS_EXTENDED) (RELAX_MIPS16_MARK_ALWAYS_EXTENDED) (RELAX_MIPS16_CLEAR_ALWAYS_EXTENDED): Shift bits. (RELAX_MIPS16_MACRO, RELAX_MIPS16_MARK_MACRO) (RELAX_MIPS16_CLEAR_MACRO): New macros. (append_insn): Pass `mips_pic', HAVE_32BIT_SYMBOLS and `mips_opts.warn_about_macros' settings to RELAX_MIPS16_ENCODE. (mips16_macro_frag): New function. (md_estimate_size_before_relax): Handle HI16/LO16 relaxation. (mips_relax_frag): Likewise. (md_convert_frag): Likewise. * testsuite/gas/mips/mips16@relax-swap3.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16e@relax-swap3.d: New test subarchitecture. * testsuite/gas/mips/micromips@relax-swap3.d: Remove trailing NOP padding. * testsuite/gas/mips/mips16-pcrel-reloc-2.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-reloc-3.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-reloc-6.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-reloc-7.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-addend-2.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-addend-3.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-absolute.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16-pcrel-absolute-1.d: Remove error output, add dump patterns. * testsuite/gas/mips/mips16@relax-swap3.l: Remove file. * testsuite/gas/mips/mips16-pcrel-reloc-2.l: Remove file. * testsuite/gas/mips/mips16-pcrel-reloc-3.l: Remove file. * testsuite/gas/mips/mips16-pcrel-reloc-6.l: Remove file. * testsuite/gas/mips/mips16-pcrel-reloc-7.l: Remove file. * testsuite/gas/mips/mips16-pcrel-addend-2.l: Remove file. * testsuite/gas/mips/mips16-pcrel-addend-3.l: Remove file. * testsuite/gas/mips/mips16-pcrel-absolute.l: Remove file. * testsuite/gas/mips/mips16-pcrel-absolute-1.l: Remove file. * testsuite/gas/mips/relax-swap3.s: Adjust trailing padding. * testsuite/gas/mips/mips16-pcrel-0.d: New test. * testsuite/gas/mips/mips16-pcrel-1.d: New test. * testsuite/gas/mips/mips16-pcrel-2.d: New test. * testsuite/gas/mips/mips16-pcrel-3.d: New test. * testsuite/gas/mips/mips16-pcrel-4.d: New test. * testsuite/gas/mips/mips16-pcrel-5.d: New test. * testsuite/gas/mips/mips16-pcrel-pic-0.d: New test. * testsuite/gas/mips/mips16-pcrel-pic-1.d: New test. * testsuite/gas/mips/mips16-pcrel-n32-0.d: New test. * testsuite/gas/mips/mips16-pcrel-n32-1.d: New test. * testsuite/gas/mips/mips16-pcrel-n64-sym32-0.d: New test. * testsuite/gas/mips/mips16-pcrel-n64-sym32-1.d: New test. * testsuite/gas/mips/mips16-pcrel-n64-0.d: New test. * testsuite/gas/mips/mips16-pcrel-n64-1.d: New test. * testsuite/gas/mips/mips16-pcrel-delay-0.d: New test. * testsuite/gas/mips/mips16-pcrel-delay-1.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-4.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-5.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-6.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-7.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-8.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-9.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-pic-8.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-pic-9.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-n32-8.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-n32-9.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-n64-sym32-8.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-n64-sym32-9.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-n64-8.d: New test. * testsuite/gas/mips/mips16-pcrel-addend-n64-9.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-2.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-3.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-5.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-7.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-n32-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-n32-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-n64-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-n64-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-n64-sym32-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-n64-sym32-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-n32-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-n32-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-6.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-sym32-4.d: New test. * testsuite/gas/mips/mips16-pcrel-absolute-pic-n64-sym32-6.d: New test. * testsuite/gas/mips/mips16-pcrel-0.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-1.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-2.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-3.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-4.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-5.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-delay-0.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-delay-1.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-addend-8.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-addend-9.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-absolute-4.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-absolute-6.l: New stderr output. * testsuite/gas/mips/mips16-pcrel-0.s: New test source. * testsuite/gas/mips/mips16-pcrel-1.s: New test source. * testsuite/gas/mips/mips16-pcrel-2.s: New test source. * testsuite/gas/mips/mips16-pcrel-3.s: New test source. * testsuite/gas/mips/mips16-pcrel-4.s: New test source. * testsuite/gas/mips/mips16-pcrel-5.s: New test source. * testsuite/gas/mips/mips16-pcrel-delay-0.s: New test source. * testsuite/gas/mips/mips16-pcrel-delay-1.s: New test source. * testsuite/gas/mips/mips16-pcrel-addend-4.s: New test source. * testsuite/gas/mips/mips16-pcrel-addend-5.s: New test source. * testsuite/gas/mips/mips16-pcrel-addend-6.s: New test source. * testsuite/gas/mips/mips16-pcrel-addend-7.s: New test source. * testsuite/gas/mips/mips16-pcrel-addend-8.s: New test source. * testsuite/gas/mips/mips16-pcrel-addend-9.s: New test source. * testsuite/gas/mips/mips16-pcrel-absolute-2.s: New test. * testsuite/gas/mips/mips16-pcrel-absolute-3.s: New test. * testsuite/gas/mips/mips16-pcrel-absolute-4.s: New test. * testsuite/gas/mips/mips16-pcrel-absolute-5.s: New test. * testsuite/gas/mips/mips16-pcrel-absolute-6.s: New test. * testsuite/gas/mips/mips16-pcrel-absolute-7.s: New test. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/mips16-pcrel-0.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-1.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-addend-2.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-addend-6.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-n32-0.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-n32-1.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d: New test. * testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog12
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp11
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-0.d41
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-1.d41
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-addend-2.d19
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-addend-6.d19
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-n32-0.d6
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-n32-1.d6
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d6
-rw-r--r--ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d6
10 files changed, 167 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 16133b8..324ab9d 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,15 @@
+2017-05-03 Maciej W. Rozycki <macro@imgtec.com>
+
+ * testsuite/ld-mips-elf/mips16-pcrel-0.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-1.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-addend-2.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-addend-6.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-n32-0.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-n32-1.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d: New test.
+ * testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d: New test.
+ * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
+
2017-05-03 H.J. Lu <hongjiu.lu@intel.com>
* testsuite/ld-elf/pr21384.d: Adjusted to accommodate
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 068ea54..13d962b 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -154,6 +154,17 @@ if $has_newabi {
[list [list ld $abi_ldflags(n64)]]
}
+run_dump_test "mips16-pcrel-0" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-pcrel-1" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-pcrel-addend-2" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "mips16-pcrel-addend-6" [list [list ld $abi_ldflags(o32)]]
+if $has_newabi {
+ run_dump_test "mips16-pcrel-n32-0" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "mips16-pcrel-n32-1" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "mips16-pcrel-n64-sym32-0" [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "mips16-pcrel-n64-sym32-1" [list [list ld $abi_ldflags(n64)]]
+}
+
run_dump_test "mips16-branch-2" [list [list ld $abi_ldflags(o32)]]
run_dump_test "mips16-branch-3" [list [list ld $abi_ldflags(o32)]]
run_dump_test "mips16-branch-addend-2" [list [list ld $abi_ldflags(o32)]]
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-0.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-0.d
new file mode 100644
index 0000000..b1bfab6
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-0.d
@@ -0,0 +1,41 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative operations 0
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-0.s
+#as: -EB -32
+#ld: -EB -Ttext 0 -e 0
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 0a00 la v0,0+010000 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> b200 lw v0,0+010004 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> 0aff la v0,0+010404 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> b2ff lw v0,0+010408 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> f400 0a00 la v0,0+010410 <.*>
+[0-9a-f]+ <[^>]*> f400 b200 lw v0,0+010414 <.*>
+[0-9a-f]+ <[^>]*> f7ff 0a1c la v0,0+010014 <.*>
+[0-9a-f]+ <[^>]*> f7ff b21c lw v0,0+010018 <.*>
+[0-9a-f]+ <[^>]*> f7ef 0a1f la v0,0+01801f <.*>
+[0-9a-f]+ <[^>]*> f7ef b21f lw v0,0+018023 <.*>
+[0-9a-f]+ <[^>]*> f010 0a00 la v0,0+008028 <.*>
+[0-9a-f]+ <[^>]*> f010 b200 lw v0,0+00802c <.*>
+[0-9a-f]+ <[^>]*> f000 6a02 li v0,2
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f030 4a10 addiu v0,-32720
+[0-9a-f]+ <[^>]*> f000 6a02 li v0,2
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f030 9a5c lw v0,-32708\(v0\)
+[0-9a-f]+ <[^>]*> f000 6a01 li v0,1
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f050 4a07 addiu v0,-32697
+[0-9a-f]+ <[^>]*> f000 6a01 li v0,1
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f050 9a53 lw v0,-32685\(v0\)
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-1.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-1.d
new file mode 100644
index 0000000..0fe3a2b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-1.d
@@ -0,0 +1,41 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative operations 1
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-1.s
+#as: -EB -32 -mips3
+#ld: -EB -Ttext 0 -e 0
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> fe40 dla v0,0+010000 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> fc40 ld v0,0+010000 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> fe5f dla v0,0+010084 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> fc5f ld v0,0+010100 <.*>
+[0-9a-f]+ <[^>]*> 6500 nop
+[0-9a-f]+ <[^>]*> f080 fe40 dla v0,0+010090 <.*>
+[0-9a-f]+ <[^>]*> f100 fc40 ld v0,0+010110 <.*>
+[0-9a-f]+ <[^>]*> f7ff fe5c dla v0,0+010014 <.*>
+[0-9a-f]+ <[^>]*> f7ff fc5c ld v0,0+010014 <.*>
+[0-9a-f]+ <[^>]*> f7ef fe5f dla v0,0+01801f <.*>
+[0-9a-f]+ <[^>]*> f7ef fc5f ld v0,0+01801f <.*>
+[0-9a-f]+ <[^>]*> f010 fe40 dla v0,0+008028 <.*>
+[0-9a-f]+ <[^>]*> f010 fc40 ld v0,0+008028 <.*>
+[0-9a-f]+ <[^>]*> f000 6a02 li v0,2
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f030 fd50 daddiu v0,-32720
+[0-9a-f]+ <[^>]*> f000 6a02 li v0,2
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f030 3a58 ld v0,-32712\(v0\)
+[0-9a-f]+ <[^>]*> f000 6a01 li v0,1
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f050 fd47 daddiu v0,-32697
+[0-9a-f]+ <[^>]*> f000 6a01 li v0,1
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f050 3a4f ld v0,-32689\(v0\)
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-addend-2.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-addend-2.d
new file mode 100644
index 0000000..d04d035
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-addend-2.d
@@ -0,0 +1,19 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative relocation with addend 2
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-addend-2.s
+#as: -EB -32
+#ld: -EB -Ttext 0x43210000 -e 0
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> f328 6a01 li v0,17185
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f264 4a04 addiu v0,8804
+[0-9a-f]+ <[^>]*> f328 6a01 li v0,17185
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f264 9a44 lw v0,8804\(v0\)
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-addend-6.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-addend-6.d
new file mode 100644
index 0000000..134f107
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-addend-6.d
@@ -0,0 +1,19 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative relocation with addend 6
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-addend-6.s
+#as: -EB -32 -mips3
+#ld: -EB -Ttext 0x43210000 -e 0
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> f328 6a01 li v0,17185
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f264 fd44 daddiu v0,8804
+[0-9a-f]+ <[^>]*> f328 6a01 li v0,17185
+[0-9a-f]+ <[^>]*> f400 3240 sll v0,16
+[0-9a-f]+ <[^>]*> f264 3a44 ld v0,8804\(v0\)
+[0-9a-f]+ <[^>]*> 6500 nop
+ \.\.\.
+ \.\.\.
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-n32-0.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-n32-0.d
new file mode 100644
index 0000000..70102a1
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-n32-0.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative operations 0 (n32)
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-0.s
+#as: -EB -n32 -mips3
+#ld: -EB -Ttext 0 -e 0
+#dump: mips16-pcrel-0.d
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-n32-1.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-n32-1.d
new file mode 100644
index 0000000..f456fda
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-n32-1.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative operations 1 (n32)
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-1.s
+#as: -EB -n32 -mips3
+#ld: -EB -Ttext 0 -e 0
+#dump: mips16-pcrel-1.d
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d
new file mode 100644
index 0000000..aad6877
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-0.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative operations 0 (n64, sym32)
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-0.s
+#as: -EB -64 -msym32 -mips3
+#ld: -EB -Ttext 0 -e 0
+#dump: mips16-pcrel-0.d
diff --git a/ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d b/ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d
new file mode 100644
index 0000000..9a1a5de
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/mips16-pcrel-n64-sym32-1.d
@@ -0,0 +1,6 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 link PC-relative operations 1 (n64, sym32)
+#source: ../../../gas/testsuite/gas/mips/mips16-pcrel-1.s
+#as: -EB -64 -msym32 -mips3
+#ld: -EB -Ttext 0 -e 0
+#dump: mips16-pcrel-1.d