diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2017-02-23 19:26:53 +0000 |
---|---|---|
committer | Maciej W. Rozycki <macro@imgtec.com> | 2017-02-23 23:45:14 +0000 |
commit | c1556ecd7843912269aba283a0fd307729fa0c3a (patch) | |
tree | 1deeb56cbddecee8f8f62c6494d72e0883be1d9b /ld/testsuite/ld-mips-elf | |
parent | a567769b813b2538bebc97d689fc0739f172028e (diff) | |
download | gdb-c1556ecd7843912269aba283a0fd307729fa0c3a.zip gdb-c1556ecd7843912269aba283a0fd307729fa0c3a.tar.gz gdb-c1556ecd7843912269aba283a0fd307729fa0c3a.tar.bz2 |
MIPS/BFD: Discard ineligible JALR relocations right away
Discard R_MIPS_JALR and R_MICROMIPS_JALR relocations associated with
jumps that cannot be converted to an equivalent branch right away in
`mips_elf_calculate_relocation' rather than letting them through to
`mips_elf_perform_relocation'. This includes cross-mode jumps which
need to flip the ISA bit or jumps to a misaligned location that cannot
be encoded with a branch, in addition to preemptible symbol references
already handled.
Cross-mode jumps are actually already rejected as the conversion is made
in `mips_elf_perform_relocation', so in this case this change only saves
some processing. Jumps to a misaligned location are however converted,
with bits causing misalignment lost, making resulting code functionally
different even if the lone effect is avoiding an address error exception
with an instruction fetch at the jump destination requested.
Add test cases suitable, also including GAS verification to confirm that
the JALR relocations explicitly requested have indeed been output in the
intermediate objects used.
bfd/
* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_JALR>
<R_MICROMIPS_JALR>: Discard relocation if `cross_mode_jump_p'
or misaligned.
gas/
* testsuite/gas/mips/jalr4.d: New test.
* testsuite/gas/mips/jalr4-n32.d: New test.
* testsuite/gas/mips/jalr4-n64.d: New test.
* testsuite/gas/mips/jalr4.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.
ld/
* testsuite/ld-mips-elf/jalr4.dd: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
Diffstat (limited to 'ld/testsuite/ld-mips-elf')
-rw-r--r-- | ld/testsuite/ld-mips-elf/jalr4.dd | 19 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 9 |
2 files changed, 27 insertions, 1 deletions
diff --git a/ld/testsuite/ld-mips-elf/jalr4.dd b/ld/testsuite/ld-mips-elf/jalr4.dd new file mode 100644 index 0000000..8e41756 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/jalr4.dd @@ -0,0 +1,19 @@ +.*: +file format .*mips.* + +Disassembly of section \.text: +[0-9a-f]+ <[^>]*> 0411000f bal 0+000040 <bar0> +[0-9a-f]+ <[^>]*> 00000000 nop +[0-9a-f]+ <[^>]*> 1000000d b 0+000040 <bar0> +[0-9a-f]+ <[^>]*> 00000000 nop +[0-9a-f]+ <[^>]*> 0320f809 jalr t9 +[0-9a-f]+ <[^>]*> 00000000 nop +[0-9a-f]+ <[^>]*> 03200008 jr t9 +[0-9a-f]+ <[^>]*> 00000000 nop +[0-9a-f]+ <[^>]*> 0320f809 jalr t9 +[0-9a-f]+ <[^>]*> 00000000 nop +[0-9a-f]+ <[^>]*> 03200008 jr t9 +[0-9a-f]+ <[^>]*> 00000000 nop + \.\.\. + \.\.\. + \.\.\. + \.\.\. diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 7fa11c5..dab0e0f 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -999,7 +999,14 @@ foreach { abi } $abis { "$abi_asflags($abi)" \ [list ../../../gas/testsuite/gas/mips/jalr3.s] \ [list "objdump -d jalr3.dd"] \ - "jalr3-${abi}"]] + "jalr3-${abi}"] \ + [list \ + "MIPS JALR reloc unaligned/cross-mode link test ($abi)" \ + "$abi_ldflags($abi) -T jalr3.ld" "" \ + "$abi_asflags($abi)" \ + [list ../../../gas/testsuite/gas/mips/jalr4.s] \ + [list "objdump {-d --prefix-addresses --show-raw-insn} jalr4.dd"] \ + "jalr4-${abi}"]] } proc build_mips_plt_lib { abi } { |