aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-06-21 16:01:27 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-06-21 18:05:18 +0100
commit912815f079a8f3c40c0968ba5140619de079e199 (patch)
tree098bd436e09913e92c8add39db353611248f38b2 /gas
parent5f68df25f869d74f0235276a81536392fd376e6d (diff)
downloadgdb-912815f079a8f3c40c0968ba5140619de079e199.zip
gdb-912815f079a8f3c40c0968ba5140619de079e199.tar.gz
gdb-912815f079a8f3c40c0968ba5140619de079e199.tar.bz2
MIPS/GAS: Use the module level ISA setting for R6 relaxation
Use the module level ISA setting rather than the last ISA selected with a `.set' directive in the source file in determination as to whether to keep PC-relative relocations and then with the original symbol referred, for the purpose of R6 linker relaxation. This is so that with e.g. code like this: b foo .set mips32r2 ... it's the command line options or any `.module' directive that decides how to encode any relocation for `foo' rather than the presence of `.set mips32r2'. gas/ * config/tc-mips.c (mips_force_relocation): Use `file_mips_opts' rather than `mips_opts' for the R6 ISA check. (mips_fix_adjustable): Likewise. * testsuite/gas/mips/pcrel-reloc-1.d: New test. * testsuite/gas/mips/pcrel-reloc-1-r6.d: New test. * testsuite/gas/mips/pcrel-reloc-2.d: New test. * testsuite/gas/mips/pcrel-reloc-2-r6.d: New test. * testsuite/gas/mips/pcrel-reloc-3.d: New test. * testsuite/gas/mips/pcrel-reloc-3-r6.d: New test. * testsuite/gas/mips/pcrel-reloc-1.s: New test source. * testsuite/gas/mips/mips.exp: Run the new tests.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog14
-rw-r--r--gas/config/tc-mips.c4
-rw-r--r--gas/testsuite/gas/mips/mips.exp7
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-1-r6.d21
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-1.d17
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-1.s31
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-2-r6.d5
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-2.d5
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-3-r6.d5
-rw-r--r--gas/testsuite/gas/mips/pcrel-reloc-3.d5
10 files changed, 112 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 4672d15..1e88b21 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,17 @@
+2016-06-21 Maciej W. Rozycki <macro@imgtec.com>
+
+ * config/tc-mips.c (mips_force_relocation): Use `file_mips_opts'
+ rather than `mips_opts' for the R6 ISA check.
+ (mips_fix_adjustable): Likewise.
+ * testsuite/gas/mips/pcrel-reloc-1.d: New test.
+ * testsuite/gas/mips/pcrel-reloc-1-r6.d: New test.
+ * testsuite/gas/mips/pcrel-reloc-2.d: New test.
+ * testsuite/gas/mips/pcrel-reloc-2-r6.d: New test.
+ * testsuite/gas/mips/pcrel-reloc-3.d: New test.
+ * testsuite/gas/mips/pcrel-reloc-3-r6.d: New test.
+ * testsuite/gas/mips/pcrel-reloc-1.s: New test source.
+ * testsuite/gas/mips/mips.exp: Run the new tests.
+
2016-06-21 Graham Markall <graham.markall@embecosm.com>
* config/tc-arc.c (check_cpu_feature, md_parse_option):
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 1a472a3..ed64b68 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -14768,7 +14768,7 @@ mips_force_relocation (fixS *fixp)
return 1;
/* We want all PC-relative relocations to be kept for R6 relaxation. */
- if (ISA_IS_R6 (mips_opts.isa)
+ if (ISA_IS_R6 (file_mips_opts.isa)
&& (fixp->fx_r_type == BFD_RELOC_16_PCREL_S2
|| fixp->fx_r_type == BFD_RELOC_MIPS_21_PCREL_S2
|| fixp->fx_r_type == BFD_RELOC_MIPS_26_PCREL_S2
@@ -17137,7 +17137,7 @@ mips_fix_adjustable (fixS *fixp)
Also, PC relative relocations for MIPS R6 need to be symbol rather than
section relative to allow linker relaxations to be performed later on. */
if (limited_pcrel_reloc_p (fixp->fx_r_type)
- && (HAVE_IN_PLACE_ADDENDS || ISA_IS_R6 (mips_opts.isa)))
+ && (HAVE_IN_PLACE_ADDENDS || ISA_IS_R6 (file_mips_opts.isa)))
return 0;
/* R_MIPS16_26 relocations against non-MIPS16 functions might resolve
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index 4071434..12ac64e 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -1316,6 +1316,13 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "pcrel-4-64"
}
+ run_dump_test "pcrel-reloc-1"
+ run_dump_test "pcrel-reloc-1-r6"
+ run_dump_test "pcrel-reloc-2"
+ run_dump_test "pcrel-reloc-2-r6"
+ run_dump_test "pcrel-reloc-3"
+ run_dump_test "pcrel-reloc-3-r6"
+
run_dump_test_arches "attr-gnu-4-0" "-32" \
[mips_arch_list_matching mips1]
run_dump_test_arches "attr-gnu-4-0" "-64" \
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-1-r6.d b/gas/testsuite/gas/mips/pcrel-reloc-1-r6.d
new file mode 100644
index 0000000..26348f4
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-1-r6.d
@@ -0,0 +1,21 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS R6 local PC-relative relocations 1
+#as: -32 -mips32r6
+#source: pcrel-reloc-1.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]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jr ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-1.d b/gas/testsuite/gas/mips/pcrel-reloc-1.d
new file mode 100644
index 0000000..4d4d21f
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-1.d
@@ -0,0 +1,17 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS local PC-relative relocations 1
+#as: -32
+#source: pcrel-reloc-1.s
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 10000007 b 00000020 <bar>
+[0-9a-f]+ <[^>]*> 10000006 b 00000020 <bar>
+[0-9a-f]+ <[^>]*> 10000005 b 00000020 <bar>
+[0-9a-f]+ <[^>]*> 10000004 b 00000020 <bar>
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
+[0-9a-f]+ <[^>]*> 03e00009 jalr zero,ra
+[0-9a-f]+ <[^>]*> 00000000 nop
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-1.s b/gas/testsuite/gas/mips/pcrel-reloc-1.s
new file mode 100644
index 0000000..7ca8f30
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-1.s
@@ -0,0 +1,31 @@
+ .text
+ .align 4, 0
+ .globl foo
+ .ent foo
+ .set noreorder
+foo:
+ b bar
+ b bar
+ b bar
+ b bar
+ .set reorder
+ .end foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16
+
+ .ent bar
+ .ifdef setmips3
+ .set mips3
+ .endif
+ .ifdef setmips64r6
+ .set mips64r6
+ .endif
+bar:
+ jalr $0, $ra
+ .end bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 16, 0
+ .space 16
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-2-r6.d b/gas/testsuite/gas/mips/pcrel-reloc-2-r6.d
new file mode 100644
index 0000000..1a56084
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-2-r6.d
@@ -0,0 +1,5 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS R6 local PC-relative relocations 2
+#as: -32 -mips32r6 --defsym setmips3=1
+#source: pcrel-reloc-1.s
+#dump: pcrel-reloc-1-r6.d
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-2.d b/gas/testsuite/gas/mips/pcrel-reloc-2.d
new file mode 100644
index 0000000..25f7f7b
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-2.d
@@ -0,0 +1,5 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS local PC-relative relocations 2
+#as: -32 --defsym setmips3=1
+#source: pcrel-reloc-1.s
+#dump: pcrel-reloc-1.d
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-3-r6.d b/gas/testsuite/gas/mips/pcrel-reloc-3-r6.d
new file mode 100644
index 0000000..9211a0e
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-3-r6.d
@@ -0,0 +1,5 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS R6 local PC-relative relocations 3
+#as: -32 -mips32r6 --defsym setmips64r6=1
+#source: pcrel-reloc-1.s
+#dump: pcrel-reloc-1-r6.d
diff --git a/gas/testsuite/gas/mips/pcrel-reloc-3.d b/gas/testsuite/gas/mips/pcrel-reloc-3.d
new file mode 100644
index 0000000..cb587b9
--- /dev/null
+++ b/gas/testsuite/gas/mips/pcrel-reloc-3.d
@@ -0,0 +1,5 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS local PC-relative relocations 3
+#as: -32 --defsym setmips64r6=1
+#source: pcrel-reloc-1.s
+#dump: pcrel-reloc-1.d