From: Maciej W. Rozycki Date: Tue, 21 Jun 2016 20:22:39 +0000 (+0100) Subject: MIPS/GAS: Handle resolved R6 PC-relative relocations X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=41947d9e38c4;p=binutils-gdb.git 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) : New switch cases. (md_apply_fix) : Move switch cases along `BFD_RELOC_MIPS_JMP'. : 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. --- diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index c598806b8f3..6891508e132 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 12ac64ee80b..4236397dcf2 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 00000000000..32619cd0f13 --- /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 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 00000004 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 00000008 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 0000000c +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> cbffffff bc 00000010 +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> cbffffff bc 00000014 +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> cbffffff bc 00000018 +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> cbffffff bc 0000001c +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00000020 +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00000024 +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00000028 +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,0000002c +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00000030 +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00000034 +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00000038 +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,0000003c +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000040 +[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000040 +[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000048 +[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00000048 +[ ]*[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 00000000000..faeb6a5f3de --- /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 +[0-9a-f]+ <[^>]*> 1000001e b 00000080 +[0-9a-f]+ <[^>]*> 1000001d b 00000080 +[0-9a-f]+ <[^>]*> 1000001c b 00000080 +[0-9a-f]+ <[^>]*> c800001b bc 00000080 +[0-9a-f]+ <[^>]*> c800001a bc 00000080 +[0-9a-f]+ <[^>]*> c8000019 bc 00000080 +[0-9a-f]+ <[^>]*> c8000018 bc 00000080 +[0-9a-f]+ <[^>]*> d8400017 beqzc v0,00000080 +[0-9a-f]+ <[^>]*> d8400016 beqzc v0,00000080 +[0-9a-f]+ <[^>]*> d8400015 beqzc v0,00000080 +[0-9a-f]+ <[^>]*> d8400014 beqzc v0,00000080 +[0-9a-f]+ <[^>]*> ec480014 lwpc v0,00000080 +[0-9a-f]+ <[^>]*> ec480013 lwpc v0,00000080 +[0-9a-f]+ <[^>]*> ec480012 lwpc v0,00000080 +[0-9a-f]+ <[^>]*> ec480011 lwpc v0,00000080 +[0-9a-f]+ <[^>]*> ec580008 ldpc v0,00000080 +[0-9a-f]+ <[^>]*> ec580008 ldpc v0,00000080 +[0-9a-f]+ <[^>]*> ec580007 ldpc v0,00000080 +[0-9a-f]+ <[^>]*> ec580007 ldpc v0,00000080 +[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 00000000000..d6906ae5022 --- /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 00000000000..a6ff8bd9740 --- /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 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 00010034 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 00010038 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 0001003c +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> cbffffff bc 00010040 +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> cbffffff bc 00010044 +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> cbffffff bc 00010048 +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> cbffffff bc 0001004c +[ ]*[0-9a-f]+: R_MIPS_PC26_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00010050 +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00010054 +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,00010058 +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> d85fffff beqzc v0,0001005c +[ ]*[0-9a-f]+: R_MIPS_PC21_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00010060 +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00010064 +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,00010068 +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec480000 lwpc v0,0001006c +[ ]*[0-9a-f]+: R_MIPS_PC19_S2 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010070 +[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010070 +[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010078 +[ ]*[0-9a-f]+: R_MIPS_PC18_S3 bar +[0-9a-f]+ <[^>]*> ec580000 ldpc v0,00010078 +[ ]*[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 00000000000..227b3fc45ba --- /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 +[0-9a-f]+ <[^>]*> 1000fff6 b 00010010 +[0-9a-f]+ <[^>]*> 1000fff5 b 00010010 +[0-9a-f]+ <[^>]*> 1000fff4 b 00010010 +[0-9a-f]+ <[^>]*> cbfffff3 bc 00010010 +[0-9a-f]+ <[^>]*> cbfffff2 bc 00010010 +[0-9a-f]+ <[^>]*> cbfffff1 bc 00010010 +[0-9a-f]+ <[^>]*> cbfffff0 bc 00010010 +[0-9a-f]+ <[^>]*> d85fffef beqzc v0,00010010 +[0-9a-f]+ <[^>]*> d85fffee beqzc v0,00010010 +[0-9a-f]+ <[^>]*> d85fffed beqzc v0,00010010 +[0-9a-f]+ <[^>]*> d85fffec beqzc v0,00010010 +[0-9a-f]+ <[^>]*> ec4fffec lwpc v0,00010010 +[0-9a-f]+ <[^>]*> ec4fffeb lwpc v0,00010010 +[0-9a-f]+ <[^>]*> ec4fffea lwpc v0,00010010 +[0-9a-f]+ <[^>]*> ec4fffe9 lwpc v0,00010010 +[0-9a-f]+ <[^>]*> ec5bfff4 ldpc v0,00010010 +[0-9a-f]+ <[^>]*> ec5bfff4 ldpc v0,00010010 +[0-9a-f]+ <[^>]*> ec5bfff3 ldpc v0,00010010 +[0-9a-f]+ <[^>]*> ec5bfff3 ldpc v0,00010010 +[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 00000000000..03e65f62fb9 --- /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 +[0-9a-f]+ <[^>]*> 10007fff b 00020004 +[0-9a-f]+ <[^>]*> ca000000 bc f800000c +[0-9a-f]+ <[^>]*> c9ffffff bc 0800000c +[0-9a-f]+ <[^>]*> d8500000 beqzc v0,ffc00014 +[0-9a-f]+ <[^>]*> d84fffff beqzc v0,00400014 +[0-9a-f]+ <[^>]*> ec4c0000 lwpc v0,fff00018 +[0-9a-f]+ <[^>]*> ec4bffff lwpc v0,00100018 +[0-9a-f]+ <[^>]*> ec5a0000 ldpc v0,fff00020 +[0-9a-f]+ <[^>]*> ec59ffff ldpc v0,00100018 + \.\.\. 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 00000000000..510ad422038 --- /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 00000000000..8fe5d8cdb3e --- /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