From: Maciej W. Rozycki Date: Tue, 21 Jun 2016 15:01:27 +0000 (+0100) Subject: MIPS/GAS: Use the module level ISA setting for R6 relaxation X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=912815f079a8f3c40c0968ba5140619de079e199;p=deliverable%2Fbinutils-gdb.git 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. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 4672d15229..1e88b21e0c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,17 @@ +2016-06-21 Maciej W. Rozycki + + * 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 * 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 1a472a3234..ed64b68936 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 4071434de9..12ac64ee80 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 0000000000..26348f42c7 --- /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 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 00000004 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 00000008 +[ ]*[0-9a-f]+: R_MIPS_PC16 bar +[0-9a-f]+ <[^>]*> 1000ffff b 0000000c +[ ]*[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 0000000000..4d4d21f4d4 --- /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 +[0-9a-f]+ <[^>]*> 10000006 b 00000020 +[0-9a-f]+ <[^>]*> 10000005 b 00000020 +[0-9a-f]+ <[^>]*> 10000004 b 00000020 +[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 0000000000..7ca8f30625 --- /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 0000000000..1a56084ad1 --- /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 0000000000..25f7f7bc0d --- /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 0000000000..9211a0e834 --- /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 0000000000..cb587b9b20 --- /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