aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-06-21 21:22:39 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-06-21 23:00:20 +0100
commit41947d9e38c4fd27b17843f328d58138193e4f19 (patch)
treeab440ef62ed51a22e1f7c1fd4214585e69afd8b9 /gas
parent717ba204e06d88ed68441e236da3688a92cf054c (diff)
downloadgdb-41947d9e38c4fd27b17843f328d58138193e4f19.zip
gdb-41947d9e38c4fd27b17843f328d58138193e4f19.tar.gz
gdb-41947d9e38c4fd27b17843f328d58138193e4f19.tar.bz2
MIPS/GAS: Handle resolved R6 PC-relative relocations
Complement commit 7361da2c952e ("Add support for MIPS R6.") and fix internal errors like: foo.s: Assembler messages: foo.s: Internal error! Assertion failure in md_apply_fix at .../gas/config/tc-mips.c:15028. Please report this bug. triggered by resolved R6 PC-relative relocations in sources containing R6 code fragments wrapped into ISA override blocks embedded within code otherwise assembled for an older ISA. gas/ * config/tc-mips.c (calculate_reloc) <BFD_RELOC_HI16_S_PCREL> <BFD_RELOC_LO16_PCREL>: New switch cases. (md_apply_fix) <BFD_RELOC_HI16_S_PCREL, BFD_RELOC_LO16_PCREL>: Move switch cases along `BFD_RELOC_MIPS_JMP'. <BFD_RELOC_MIPS_21_PCREL_S2, BFD_RELOC_MIPS_26_PCREL_S2> <BFD_RELOC_MIPS_18_PCREL_S3, BFD_RELOC_MIPS_19_PCREL_S2>: Handle the resolved case. * testsuite/gas/mips/pcrel-reloc-4.d: New test. * testsuite/gas/mips/pcrel-reloc-4-r6.d: New test. * testsuite/gas/mips/pcrel-reloc-5.d: New test. * testsuite/gas/mips/pcrel-reloc-5-r6.d: New test. * testsuite/gas/mips/pcrel-reloc-6.d: New test. * testsuite/gas/mips/pcrel-reloc-6.l: New list test. * testsuite/gas/mips/pcrel-reloc-4.s: New test source. * testsuite/gas/mips/pcrel-reloc-6.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests.
Diffstat (limited to 'gas')
-rw-r--r--gas/config/tc-mips.c62
-rw-r--r--gas/testsuite/gas/mips/mips.exp7
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-4-r6.d71
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-4.d43
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-4.s83
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-5-r6.d71
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-5.d43
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-6.d19
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-6.l11
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-6.s25
10 files changed, 427 insertions, 8 deletions
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index c598806..6891508 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -6972,6 +6972,7 @@ calculate_reloc (bfd_reloc_code_real_type reloc, offsetT operand,
return TRUE;
case BFD_RELOC_HI16_S:
+ case BFD_RELOC_HI16_S_PCREL:
case BFD_RELOC_MICROMIPS_HI16_S:
case BFD_RELOC_MIPS16_HI16_S:
*result = ((operand + 0x8000) >> 16) & 0xffff;
@@ -6984,6 +6985,7 @@ calculate_reloc (bfd_reloc_code_real_type reloc, offsetT operand,
return TRUE;
case BFD_RELOC_LO16:
+ case BFD_RELOC_LO16_PCREL:
case BFD_RELOC_MICROMIPS_LO16:
case BFD_RELOC_MIPS16_LO16:
*result = operand & 0xffff;
@@ -14944,6 +14946,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
case BFD_RELOC_MIPS_GOT_LO16:
case BFD_RELOC_MIPS_CALL_HI16:
case BFD_RELOC_MIPS_CALL_LO16:
+ case BFD_RELOC_HI16_S_PCREL:
+ case BFD_RELOC_LO16_PCREL:
case BFD_RELOC_MIPS16_GPREL:
case BFD_RELOC_MIPS16_GOT16:
case BFD_RELOC_MIPS16_CALL16:
@@ -15025,12 +15029,39 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
break;
case BFD_RELOC_MIPS_21_PCREL_S2:
+ if ((*valP & 0x3) != 0)
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("branch to misaligned address (%lx)"), (long) *valP);
+ if (!fixP->fx_done)
+ break;
+
+ if (*valP + 0x400000 <= 0x7fffff)
+ {
+ insn = read_insn (buf);
+ insn |= (*valP >> 2) & 0x1fffff;
+ write_insn (buf, insn);
+ }
+ else
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("branch out of range"));
+ break;
+
case BFD_RELOC_MIPS_26_PCREL_S2:
if ((*valP & 0x3) != 0)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("branch to misaligned address (%lx)"), (long) *valP);
+ if (!fixP->fx_done)
+ break;
- gas_assert (!fixP->fx_done);
+ if (*valP + 0x8000000 <= 0xfffffff)
+ {
+ insn = read_insn (buf);
+ insn |= (*valP >> 2) & 0x3ffffff;
+ write_insn (buf, insn);
+ }
+ else
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("branch out of range"));
break;
case BFD_RELOC_MIPS_18_PCREL_S3:
@@ -15042,8 +15073,18 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("PC-relative access using misaligned offset (%lx)"),
(long) fixP->fx_offset);
+ if (!fixP->fx_done)
+ break;
- gas_assert (!fixP->fx_done);
+ if (*valP + 0x100000 <= 0x1fffff)
+ {
+ insn = read_insn (buf);
+ insn |= (*valP >> 3) & 0x3ffff;
+ write_insn (buf, insn);
+ }
+ else
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("PC-relative access out of range"));
break;
case BFD_RELOC_MIPS_19_PCREL_S2:
@@ -15051,13 +15092,18 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("PC-relative access to misaligned address (%lx)"),
(long) *valP);
+ if (!fixP->fx_done)
+ break;
- gas_assert (!fixP->fx_done);
- break;
-
- case BFD_RELOC_HI16_S_PCREL:
- case BFD_RELOC_LO16_PCREL:
- gas_assert (!fixP->fx_done);
+ if (*valP + 0x100000 <= 0x1fffff)
+ {
+ insn = read_insn (buf);
+ insn |= (*valP >> 2) & 0x7ffff;
+ write_insn (buf, insn);
+ }
+ else
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ _("PC-relative access out of range"));
break;
case BFD_RELOC_16_PCREL_S2:
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index 12ac64e..4236397 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -1322,6 +1322,13 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "pcrel-reloc-2-r6"
run_dump_test "pcrel-reloc-3"
run_dump_test "pcrel-reloc-3-r6"
+ run_dump_test "pcrel-reloc-4"
+ run_dump_test "pcrel-reloc-4-r6"
+ run_dump_test "pcrel-reloc-5"
+ run_dump_test "pcrel-reloc-5-r6"
+ run_dump_test "pcrel-reloc-6"
+ run_list_test "pcrel-reloc-6" "-32 --defsym offset=4" \
+ "MIPS local PC-relative relocations 6b"
run_dump_test_arches "attr-gnu-4-0" "-32" \
[mips_arch_list_matching mips1]
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-4-r6.d b/gas/testsuite/gas/mips/pcrel-reloc-4-r6.d
new file mode 100644
index 0000000..32619cd
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-4-r6.d
@@ -0,0 +1,71 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -mmips:isa64r6
+#name: MIPS local PC-relative relocations 4
+#as: -32 -mips32r6
+#source: pcrel-reloc-4.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 1000ffff b 00000000 <foo>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> 1000ffff b 00000004 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> 1000ffff b 00000008 <foo\+0x8>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> 1000ffff b 0000000c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 00000010 <foo\+0x10>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 00000014 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 00000018 <foo\+0x18>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 0000001c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00000020 <foo\+0x20>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00000024 <foo\+0x24>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00000028 <foo\+0x28>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,0000002c <foo\+0x2c>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00000030 <foo\+0x30>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00000034 <foo\+0x34>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00000038 <foo\+0x38>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,0000003c <foo\+0x3c>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000040 <foo\+0x40>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000040 <foo\+0x40>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000048 <foo\+0x48>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000048 <foo\+0x48>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420014 addiu v0,v0,20
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420014 addiu v0,v0,20
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420014 addiu v0,v0,20
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420014 addiu v0,v0,20
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-4.d b/gas/testsuite/gas/mips/pcrel-reloc-4.d
new file mode 100644
index 0000000..faeb6a5
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-4.d
@@ -0,0 +1,43 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -mmips:isa64r6
+#name: MIPS local PC-relative relocations 4
+#as: -32
+#source: pcrel-reloc-4.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 1000001f b 00000080 <bar>
+[0-9a-f]+ <[^>]*> 1000001e b 00000080 <bar>
+[0-9a-f]+ <[^>]*> 1000001d b 00000080 <bar>
+[0-9a-f]+ <[^>]*> 1000001c b 00000080 <bar>
+[0-9a-f]+ <[^>]*> c800001b bc 00000080 <bar>
+[0-9a-f]+ <[^>]*> c800001a bc 00000080 <bar>
+[0-9a-f]+ <[^>]*> c8000019 bc 00000080 <bar>
+[0-9a-f]+ <[^>]*> c8000018 bc 00000080 <bar>
+[0-9a-f]+ <[^>]*> d8400017 beqzc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> d8400016 beqzc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> d8400015 beqzc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> d8400014 beqzc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec480014 lwpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec480013 lwpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec480012 lwpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec480011 lwpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec580008 ldpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec580008 ldpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec580007 ldpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec580007 ldpc v0,00000080 <bar>
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[0-9a-f]+ <[^>]*> 2442ffc0 addiu v0,v0,-64
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[0-9a-f]+ <[^>]*> 2442ffb8 addiu v0,v0,-72
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[0-9a-f]+ <[^>]*> 2442ffb0 addiu v0,v0,-80
+[0-9a-f]+ <[^>]*> ec5e0001 auipc v0,0x1
+[0-9a-f]+ <[^>]*> 2442ffa8 addiu v0,v0,-88
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-4.s b/gas/testsuite/gas/mips/pcrel-reloc-4.s
new file mode 100644
index 0000000..d6906ae
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-4.s
@@ -0,0 +1,83 @@
+ .text
+
+ .ifdef reverse
+ .ent baz
+baz:
+ jalr $0, $ra
+ .end baz
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 16, 0
+ .space 16
+
+ .ent bar
+bar:
+ jalr $0, $ra
+ .end bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+ .endif
+
+ .align 4, 0
+ .globl foo
+ .ent foo
+ .set noreorder
+foo:
+ b bar
+ b bar
+ b bar
+ b bar
+ .set mips64r6
+ bc bar
+ bc bar
+ bc bar
+ bc bar
+ beqzc $2, bar
+ beqzc $2, bar
+ beqzc $2, bar
+ beqzc $2, bar
+ lwpc $2, bar
+ lwpc $2, bar
+ lwpc $2, bar
+ lwpc $2, bar
+ ldpc $2, bar
+ ldpc $2, bar
+ ldpc $2, bar
+ ldpc $2, bar
+ auipc $2, %pcrel_hi(baz)
+ addiu $2, %pcrel_lo(baz + 4)
+ auipc $2, %pcrel_hi(baz)
+ addiu $2, %pcrel_lo(baz + 4)
+ auipc $2, %pcrel_hi(baz)
+ addiu $2, %pcrel_lo(baz + 4)
+ auipc $2, %pcrel_hi(baz)
+ addiu $2, %pcrel_lo(baz + 4)
+ .set mips0
+ .set reorder
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .ifndef reverse
+ .ent bar
+bar:
+ jalr $0, $ra
+ .end bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 16, 0
+ .space 16
+
+ .ent baz
+baz:
+ jalr $0, $ra
+ .end baz
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+ .endif
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-5-r6.d b/gas/testsuite/gas/mips/pcrel-reloc-5-r6.d
new file mode 100644
index 0000000..a6ff8bd
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-5-r6.d
@@ -0,0 +1,71 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -mmips:isa64r6
+#name: MIPS local PC-relative relocations 5
+#as: -32 -mips32r6 --defsym reverse=1
+#source: pcrel-reloc-4.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 1000ffff b 00010030 <foo>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> 1000ffff b 00010034 <foo\+0x4>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> 1000ffff b 00010038 <foo\+0x8>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> 1000ffff b 0001003c <foo\+0xc>
+[ ]*[0-9a-f]+: R_MIPS_PC16 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 00010040 <foo\+0x10>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 00010044 <foo\+0x14>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 00010048 <foo\+0x18>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> cbffffff bc 0001004c <foo\+0x1c>
+[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00010050 <foo\+0x20>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00010054 <foo\+0x24>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00010058 <foo\+0x28>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> d85fffff beqzc v0,0001005c <foo\+0x2c>
+[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00010060 <foo\+0x30>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00010064 <foo\+0x34>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00010068 <foo\+0x38>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec480000 lwpc v0,0001006c <foo\+0x3c>
+[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010070 <foo\+0x40>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010070 <foo\+0x40>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010078 <foo\+0x48>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010078 <foo\+0x48>
+[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar
+[0-9a-f]+ <[^>]*> ec5e0000 auipc v0,0x0
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420004 addiu v0,v0,4
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+[0-9a-f]+ <[^>]*> ec5e0000 auipc v0,0x0
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420004 addiu v0,v0,4
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+[0-9a-f]+ <[^>]*> ec5e0000 auipc v0,0x0
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420004 addiu v0,v0,4
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+[0-9a-f]+ <[^>]*> ec5e0000 auipc v0,0x0
+[ ]*[0-9a-f]+: R_MIPS_PCHI16 \.text
+[0-9a-f]+ <[^>]*> 24420004 addiu v0,v0,4
+[ ]*[0-9a-f]+: R_MIPS_PCLO16 \.text
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-5.d b/gas/testsuite/gas/mips/pcrel-reloc-5.d
new file mode 100644
index 0000000..227b3fc
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-5.d
@@ -0,0 +1,43 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -mmips:isa64r6
+#name: MIPS local PC-relative relocations 5
+#as: -32 --defsym reverse=1
+#source: pcrel-reloc-4.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 1000fff7 b 00010010 <bar>
+[0-9a-f]+ <[^>]*> 1000fff6 b 00010010 <bar>
+[0-9a-f]+ <[^>]*> 1000fff5 b 00010010 <bar>
+[0-9a-f]+ <[^>]*> 1000fff4 b 00010010 <bar>
+[0-9a-f]+ <[^>]*> cbfffff3 bc 00010010 <bar>
+[0-9a-f]+ <[^>]*> cbfffff2 bc 00010010 <bar>
+[0-9a-f]+ <[^>]*> cbfffff1 bc 00010010 <bar>
+[0-9a-f]+ <[^>]*> cbfffff0 bc 00010010 <bar>
+[0-9a-f]+ <[^>]*> d85fffef beqzc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> d85fffee beqzc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> d85fffed beqzc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> d85fffec beqzc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec4fffec lwpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec4fffeb lwpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec4fffea lwpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec4fffe9 lwpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec5bfff4 ldpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec5bfff4 ldpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec5bfff3 ldpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec5bfff3 ldpc v0,00010010 <bar>
+[0-9a-f]+ <[^>]*> ec5effff auipc v0,0xffff
+[0-9a-f]+ <[^>]*> 2442ff80 addiu v0,v0,-128
+[0-9a-f]+ <[^>]*> ec5effff auipc v0,0xffff
+[0-9a-f]+ <[^>]*> 2442ff78 addiu v0,v0,-136
+[0-9a-f]+ <[^>]*> ec5effff auipc v0,0xffff
+[0-9a-f]+ <[^>]*> 2442ff70 addiu v0,v0,-144
+[0-9a-f]+ <[^>]*> ec5effff auipc v0,0xffff
+[0-9a-f]+ <[^>]*> 2442ff68 addiu v0,v0,-152
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-6.d b/gas/testsuite/gas/mips/pcrel-reloc-6.d
new file mode 100644
index 0000000..03e65f6
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-6.d
@@ -0,0 +1,19 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -mmips:isa64r6
+#name: MIPS local PC-relative relocations 6a
+#as: -32 --defsym offset=0
+#source: pcrel-reloc-6.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 10008000 b fffe0004 <foo\+0xfffe0004>
+[0-9a-f]+ <[^>]*> 10007fff b 00020004 <foo\+0x20004>
+[0-9a-f]+ <[^>]*> ca000000 bc f800000c <foo\+0xf800000c>
+[0-9a-f]+ <[^>]*> c9ffffff bc 0800000c <foo\+0x800000c>
+[0-9a-f]+ <[^>]*> d8500000 beqzc v0,ffc00014 <foo\+0xffc00014>
+[0-9a-f]+ <[^>]*> d84fffff beqzc v0,00400014 <foo\+0x400014>
+[0-9a-f]+ <[^>]*> ec4c0000 lwpc v0,fff00018 <foo\+0xfff00018>
+[0-9a-f]+ <[^>]*> ec4bffff lwpc v0,00100018 <foo\+0x100018>
+[0-9a-f]+ <[^>]*> ec5a0000 ldpc v0,fff00020 <foo\+0xfff00020>
+[0-9a-f]+ <[^>]*> ec59ffff ldpc v0,00100018 <foo\+0x100018>
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-6.l b/gas/testsuite/gas/mips/pcrel-reloc-6.l
new file mode 100644
index 0000000..510ad42
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-6.l
@@ -0,0 +1,11 @@
+.*: Assembler messages:
+.*:9: Error: branch out of range
+.*:10: Error: branch out of range
+.*:11: Error: branch out of range
+.*:12: Error: branch out of range
+.*:13: Error: branch out of range
+.*:14: Error: branch out of range
+.*:15: Error: PC-relative access out of range
+.*:16: Error: PC-relative access out of range
+.*:17: Error: PC-relative access out of range
+.*:18: Error: PC-relative access out of range
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-6.s b/gas/testsuite/gas/mips/pcrel-reloc-6.s
new file mode 100644
index 0000000..8fe5d8c
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-6.s
@@ -0,0 +1,25 @@
+ .text
+ .abicalls
+ .align 4, 0
+ .globl foo
+ .ent foo
+ .set noreorder
+ .set mips64r6
+foo:
+ b (. + 4) - (0x20000 + offset)
+ b (. + 4) + (0x1fffc + offset)
+ bc (. + 4) - (0x8000000 + offset)
+ bc (. + 4) + (0x7fffffc + offset)
+ beqzc $2, (. + 4) - (0x400000 + offset)
+ beqzc $2, (. + 4) + (0x3ffffc + offset)
+ lwpc $2, . - (0x100000 + offset)
+ lwpc $2, . + (0xffffc + offset)
+ ldpc $2, . - (0x100000 + (offset << 1))
+ ldpc $2, (. - 4) + (0xffff8 + (offset << 1))
+ .set mips0
+ .set reorder
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16