aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2017-08-30 16:03:31 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2017-08-30 16:07:45 +0100
commit70e65ca8e5d1fc984d58f6137c290e807fe772a5 (patch)
tree0943c3adf717058f551e0ef7fd3d1319da584b59 /gas
parent37b2d327512baf2f39020e44958fd1f11db46a91 (diff)
downloadfsf-binutils-gdb-70e65ca8e5d1fc984d58f6137c290e807fe772a5.zip
fsf-binutils-gdb-70e65ca8e5d1fc984d58f6137c290e807fe772a5.tar.gz
fsf-binutils-gdb-70e65ca8e5d1fc984d58f6137c290e807fe772a5.tar.bz2
MIPS/BFD: Correct microMIPS cross-mode BAL to JALX relaxation
Fix a bug in commit a6ebf6169a1b ("MIPS: Convert cross-mode BAL to JALX") and in BFD linker relaxation correct the microMIPS interpretation of the branch offset, which is supposed to be shifted by 1 bit, rather than 2 as in the regular MIPS case. bfd/ * elfxx-mips.c (mips_elf_perform_relocation): Correct microMIPS branch offset interpretation. gas/ * testsuite/gas/mips/branch-addend-micromips.d: New test. * testsuite/gas/mips/branch-addend-micromips-n32.d: New test. * testsuite/gas/mips/branch-addend-micromips-n64.d: New test. * testsuite/gas/mips/branch-addend-micromips.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests. ld/ * testsuite/ld-mips-elf/bal-jalx-addend-micromips.d: New test. * testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d: New test. * testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d: New test. * testsuite/ld-mips-elf/bal-jalx-local-micromips.d: New test. * testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d: New test. * testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-micromips.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d: New test. * testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d: New test. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog8
-rw-r--r--gas/testsuite/gas/mips/branch-addend-micromips-n32.d23
-rw-r--r--gas/testsuite/gas/mips/branch-addend-micromips-n64.d27
-rw-r--r--gas/testsuite/gas/mips/branch-addend-micromips.d22
-rw-r--r--gas/testsuite/gas/mips/branch-addend-micromips.s31
-rw-r--r--gas/testsuite/gas/mips/mips.exp3
6 files changed, 114 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index a71ed28..b498d2e 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,13 @@
2017-08-30 Maciej W. Rozycki <macro@imgtec.com>
+ * testsuite/gas/mips/branch-addend-micromips.d: New test.
+ * testsuite/gas/mips/branch-addend-micromips-n32.d: New test.
+ * testsuite/gas/mips/branch-addend-micromips-n64.d: New test.
+ * testsuite/gas/mips/branch-addend-micromips.s: New test source.
+ * testsuite/gas/mips/mips.exp: Run the new tests.
+
+2017-08-30 Maciej W. Rozycki <macro@imgtec.com>
+
* config/tc-mips.c (md_convert_frag): Respect
`mips_ignore_branch_isa'.
* testsuite/gas/mips/branch-local-5.d: New test.
diff --git a/gas/testsuite/gas/mips/branch-addend-micromips-n32.d b/gas/testsuite/gas/mips/branch-addend-micromips-n32.d
new file mode 100644
index 0000000..085cc22
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-addend-micromips-n32.d
@@ -0,0 +1,23 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS BAL addend encoding (n32)
+#as: -n32 -march=from-abi
+#source: branch-addend-micromips.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 00000027 nor zero,zero,zero
+[0-9a-f]+ <[^>]*> 03e00009 jalr zero,ra
+[0-9a-f]+ <[^>]*> 00000027 nor zero,zero,zero
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 0000 bal 00001018 <bar\+0x8>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 foo\+0xfffc
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 0000 bal 00001020 <bar\+0x10>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0xfffc
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 001f 0f3c jr ra
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-addend-micromips-n64.d b/gas/testsuite/gas/mips/branch-addend-micromips-n64.d
new file mode 100644
index 0000000..65d0cd2
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-addend-micromips-n64.d
@@ -0,0 +1,27 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS BAL addend encoding (n64)
+#as: -64 -march=from-abi
+#source: branch-addend-micromips.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 00000027 nor zero,zero,zero
+[0-9a-f]+ <[^>]*> 03e00009 jalr zero,ra
+[0-9a-f]+ <[^>]*> 00000027 nor zero,zero,zero
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 0000 bal 0000000000001018 <bar\+0x8>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 foo\+0xfffc
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0xfffc
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0xfffc
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 0000 bal 0000000000001020 <bar\+0x10>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar\+0xfffc
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0xfffc
+[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0xfffc
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 001f 0f3c jr ra
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-addend-micromips.d b/gas/testsuite/gas/mips/branch-addend-micromips.d
new file mode 100644
index 0000000..345d9df
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-addend-micromips.d
@@ -0,0 +1,22 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: microMIPS BAL addend encoding
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+ \.\.\.
+[0-9a-f]+ <[^>]*> 00000027 nor zero,zero,zero
+[0-9a-f]+ <[^>]*> 03e00009 jalr zero,ra
+[0-9a-f]+ <[^>]*> 00000027 nor zero,zero,zero
+[0-9a-f]+ <[^>]*> 00000000 nop
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 7ffe bal 00011014 <bar\+0x10004>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 foo
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 7ffe bal 0001101c <bar\+0x1000c>
+[ ]*[0-9a-f]+: R_MICROMIPS_PC16_S1 bar
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 001f 0f3c jr ra
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/branch-addend-micromips.s b/gas/testsuite/gas/mips/branch-addend-micromips.s
new file mode 100644
index 0000000..91d7c8f
--- /dev/null
+++ b/gas/testsuite/gas/mips/branch-addend-micromips.s
@@ -0,0 +1,31 @@
+ .text
+ .set noreorder
+ .space 0x1000
+
+ .align 4
+ .set nomicromips
+ .globl foo
+ .ent foo
+foo:
+ nor $0, $0
+ jalr $0, $ra
+ nor $0, $0
+ .end foo
+
+ .align 4
+ .set micromips
+ .globl bar
+ .ent bar
+bar:
+ nor $0, $0
+ bal foo + 0x10000
+ nor $0, $0
+ bal bar + 0x10000
+ nor $0, $0
+ jalr $0, $ra
+ nor $0, $0
+ .end bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index e67473b..c71dca4 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -678,9 +678,12 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "branch-local-n64-7"
}
run_dump_test "branch-addend"
+ run_dump_test "branch-addend-micromips"
if $has_newabi {
run_dump_test "branch-addend-n32"
+ run_dump_test "branch-addend-micromips-n32"
run_dump_test "branch-addend-n64"
+ run_dump_test "branch-addend-micromips-n64"
}
run_dump_test "branch-absolute"
run_dump_test "branch-absolute-addend"