aboutsummaryrefslogtreecommitdiff
path: root/ld
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 /ld
parent37b2d327512baf2f39020e44958fd1f11db46a91 (diff)
downloadgdb-70e65ca8e5d1fc984d58f6137c290e807fe772a5.zip
gdb-70e65ca8e5d1fc984d58f6137c290e807fe772a5.tar.gz
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 'ld')
-rw-r--r--ld/ChangeLog23
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips.d22
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-local-micromips.d20
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d22
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d6
-rw-r--r--ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips.d6
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp21
14 files changed, 162 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 9e697e6..8b01f54 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,26 @@
+2017-08-30 Maciej W. Rozycki <macro@imgtec.com>
+
+ * 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.
+
2017-08-30 Alan Modra <amodra@gmail.com>
* testsuite/ld-powerpc/tls.s: Add calls with tls markers.
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d b/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d
new file mode 100644
index 0000000..9c7aca5
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n32.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX addend calculation (n32)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+#dump: bal-jalx-addend-micromips.d
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d b/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d
new file mode 100644
index 0000000..e254c65
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips-n64.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX addend calculation (n64)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+#dump: bal-jalx-addend-micromips.d
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips.d b/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips.d
new file mode 100644
index 0000000..e066f5d
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-addend-micromips.d
@@ -0,0 +1,22 @@
+#name: microMIPS BAL/JALX addend calculation
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +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]+ <[^>]*> f300 4400 jalx 0*1c011000 <.*>
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 7ff8 bal 0*1c011010 <.*>
+[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/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d b/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d
new file mode 100644
index 0000000..16fcb0a
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n32.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL to JALX conversion for local symbol (n32)
+#source: ../../../gas/testsuite/gas/mips/branch-local-7.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+#dump: bal-jalx-local-micromips.d
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d b/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d
new file mode 100644
index 0000000..d13a9ea
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips-n64.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL to JALX conversion for local symbol (n64)
+#source: ../../../gas/testsuite/gas/mips/branch-local-7.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+#dump: bal-jalx-local-micromips.d
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips.d b/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips.d
new file mode 100644
index 0000000..e944d3b
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-local-micromips.d
@@ -0,0 +1,20 @@
+#name: microMIPS BAL to JALX conversion for local symbol
+#source: ../../../gas/testsuite/gas/mips/branch-local-7.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +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]+ <[^>]*> f300 0400 jalx 0*1c001000 <foo>
+[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/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d b/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d
new file mode 100644
index 0000000..9a293c5
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n32.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX in PIC mode (ignore branch ISA, n32)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000 -shared --ignore-branch-isa
+#objdump: -dr --prefix-addresses --show-raw-insn
+#dump: bal-jalx-pic-ignore-micromips.d
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d b/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d
new file mode 100644
index 0000000..2b78bb9
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips-n64.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX in PIC mode (ignore branch ISA, n64)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000 -shared --ignore-branch-isa
+#objdump: -dr --prefix-addresses --show-raw-insn
+#dump: bal-jalx-pic-ignore-micromips.d
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d b/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d
new file mode 100644
index 0000000..0b48b3a
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-pic-ignore-micromips.d
@@ -0,0 +1,22 @@
+#name: microMIPS BAL/JALX in PIC mode (ignore branch ISA)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000 -shared --ignore-branch-isa
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +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 7ff4 bal 0*1c011000 <.*>
+[0-9a-f]+ <[^>]*> 0000 02d0 not zero,zero
+[0-9a-f]+ <[^>]*> 4060 7ff8 bal 0*1c011010 <.*>
+[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/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d b/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d
new file mode 100644
index 0000000..3b25dc7
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n32.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX in PIC mode (n32)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -n32 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000 -shared
+#error: \A[^\n]*: In function `bar':\n
+#error: \(\.text\+0x1014\): Unsupported branch between ISA modes\Z
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d b/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d
new file mode 100644
index 0000000..d39f114
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips-n64.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX in PIC mode (n64)
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -64 -march=from-abi
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000 -shared
+#error: \A[^\n]*: In function `bar':\n
+#error: \(\.text\+0x1014\): Unsupported branch between ISA modes\Z
diff --git a/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips.d b/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips.d
new file mode 100644
index 0000000..7404d25
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/bal-jalx-pic-micromips.d
@@ -0,0 +1,6 @@
+#name: microMIPS BAL/JALX in PIC mode
+#source: ../../../gas/testsuite/gas/mips/branch-addend-micromips.s
+#as: -EB -32
+#ld: -EB -Ttext 0x1c000000 -e 0x1c000000 -shared
+#error: \A[^\n]*: In function `bar':\n
+#error: \(\.text\+0x1014\): Unsupported branch between ISA modes\Z
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 4008da0..96f57bf 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -251,22 +251,43 @@ if { $linux_gnu } {
run_dump_test "jalx-addend" [list [list ld $abi_ldflags(o32)]]
run_dump_test "jalx-local" [list [list ld $abi_ldflags(o32)]]
run_dump_test "bal-jalx-addend" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-addend-micromips" [list [list ld $abi_ldflags(o32)]]
run_dump_test "bal-jalx-local" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-local-micromips" [list [list ld $abi_ldflags(o32)]]
run_dump_test "bal-jalx-pic" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-pic-micromips" [list [list ld $abi_ldflags(o32)]]
run_dump_test "bal-jalx-pic-ignore" [list [list ld $abi_ldflags(o32)]]
+run_dump_test "bal-jalx-pic-ignore-micromips" \
+ [list [list ld $abi_ldflags(o32)]]
if $has_newabi {
run_dump_test "jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
run_dump_test "jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
run_dump_test "bal-jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "bal-jalx-addend-micromips-n32" \
+ [list [list ld $abi_ldflags(n32)]]
run_dump_test "bal-jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "bal-jalx-local-micromips-n32" \
+ [list [list ld $abi_ldflags(n32)]]
run_dump_test "bal-jalx-pic-n32" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "bal-jalx-pic-micromips-n32" \
+ [list [list ld $abi_ldflags(n32)]]
run_dump_test "bal-jalx-pic-ignore-n32" [list [list ld $abi_ldflags(n32)]]
+ run_dump_test "bal-jalx-pic-ignore-micromips-n32" \
+ [list [list ld $abi_ldflags(n32)]]
run_dump_test "jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
run_dump_test "jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
run_dump_test "bal-jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "bal-jalx-addend-micromips-n64" \
+ [list [list ld $abi_ldflags(n64)]]
run_dump_test "bal-jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "bal-jalx-local-micromips-n64" \
+ [list [list ld $abi_ldflags(n64)]]
run_dump_test "bal-jalx-pic-n64" [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "bal-jalx-pic-micromips-n64" \
+ [list [list ld $abi_ldflags(n64)]]
run_dump_test "bal-jalx-pic-ignore-n64" [list [list ld $abi_ldflags(n64)]]
+ run_dump_test "bal-jalx-pic-ignore-micromips-n64" \
+ [list [list ld $abi_ldflags(n64)]]
}
run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]