This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed] MIPS/GAS: Use the module level ISA setting for R6 relaxation
- From: "Maciej W. Rozycki" <macro at imgtec dot com>
- To: <binutils at sourceware dot org>
- Date: Tue, 21 Jun 2016 18:07:34 +0100
- Subject: [committed] MIPS/GAS: Use the module level ISA setting for R6 relaxation
- Authentication-results: sourceware.org; auth=none
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.
---
I have applied this change.
Maciej
binutils-mips-gas-mips-opts-r6-fix.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2016-06-21 14:55:13.388471182 +0100
+++ binutils/gas/config/tc-mips.c 2016-06-21 17:28:15.644200095 +0100
@@ -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: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp 2016-06-21 15:00:16.159820651 +0100
+++ binutils/gas/testsuite/gas/mips/mips.exp 2016-06-21 17:28:15.088824945 +0100
@@ -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" \
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-1-r6.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-1-r6.d 2016-06-21 15:00:31.999613716 +0100
@@ -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
+ \.\.\.
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-1.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-1.d 2016-06-21 15:00:32.012745467 +0100
@@ -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
+ \.\.\.
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-1.s
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-1.s 2016-06-21 15:00:32.025828593 +0100
@@ -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
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-2-r6.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-2-r6.d 2016-06-21 16:44:05.309940791 +0100
@@ -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
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-2.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-2.d 2016-06-21 16:44:32.313946312 +0100
@@ -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
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-3-r6.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-3-r6.d 2016-06-21 16:44:16.908433347 +0100
@@ -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
Index: binutils/gas/testsuite/gas/mips/pcrel-reloc-3.d
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/pcrel-reloc-3.d 2016-06-21 16:44:55.585246664 +0100
@@ -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