]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
MIPS/GAS: Use the module level ISA setting for R6 relaxation
authorMaciej W. Rozycki <macro@imgtec.com>
Tue, 21 Jun 2016 15:01:27 +0000 (16:01 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Tue, 21 Jun 2016 17:05:18 +0000 (18:05 +0100)
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.

gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/pcrel-reloc-1-r6.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-reloc-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-reloc-1.s [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-reloc-2-r6.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-reloc-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-reloc-3-r6.d [new file with mode: 0644]
gas/testsuite/gas/mips/pcrel-reloc-3.d [new file with mode: 0644]

index 4672d15229e35cf30965ede98d0cacad6b9d6cb1..1e88b21e0c06abe537c6bfb2637229614c3c3fcb 100644 (file)
@@ -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):
index 1a472a32342f2b123924648b3fd8cad833e6cadd..ed64b6893641e4940c91c531ed98ae66fd681113 100644 (file)
@@ -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
index 4071434de955dd95150991ede6c95c4b4b86bd08..12ac64ee80becaa308b0dd5f89b5e9026f832b0c 100644 (file)
@@ -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 (file)
index 0000000..26348f4
--- /dev/null
@@ -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 (file)
index 0000000..4d4d21f
--- /dev/null
@@ -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 (file)
index 0000000..7ca8f30
--- /dev/null
@@ -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 (file)
index 0000000..1a56084
--- /dev/null
@@ -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 (file)
index 0000000..25f7f7b
--- /dev/null
@@ -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 (file)
index 0000000..9211a0e
--- /dev/null
@@ -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 (file)
index 0000000..cb587b9
--- /dev/null
@@ -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