diff options
author | Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com> | 2019-05-16 12:12:33 +0530 |
---|---|---|
committer | Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com> | 2019-05-21 12:48:06 +0530 |
commit | 7622049e0bef81fab900860400838bc977449892 (patch) | |
tree | 31038b59df87994bae534de94b70c8c7d7441634 /ld | |
parent | 338ba75534fbfeb64d7009f29a89f25826a1f4d2 (diff) | |
download | gdb-7622049e0bef81fab900860400838bc977449892.zip gdb-7622049e0bef81fab900860400838bc977449892.tar.gz gdb-7622049e0bef81fab900860400838bc977449892.tar.bz2 |
Fix PR 24571 - Relaxation does not shorten jmp or call to target at pc-relative range boundary
The range check done to transform an absolute call/jump to a pc-relative one is
off-by-one, and that causes this shortening optimization to be missed if the
branch target is right at the range boundary.
In the non-shrinkable case, the range is what is mentioned in the ISA - -4094
bytes in the backward direction, and 4096 bytes in the positive direction.
In the shrinkable case, the forward jump range increases by two bytes (deleted
because of the shortening from call/jmp to rcall/rjmp), and therefore, the
range is -4094 in the reverse, and 4098 in the positive direction.
Fix the ranges for !shrinkable and shrinkable cases, and add a test caes to
ensure jumps to max forward and backward ranges get relaxed to rjmp.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-avr/relax-insn-at-range-boundary.d | 17 | ||||
-rw-r--r-- | ld/testsuite/ld-avr/relax-insn-at-range-boundary.s | 11 |
3 files changed, 34 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 20be135..e038e40 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,11 @@ 2019-05-21 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com> + PR ld/24571 + * ld/testsuite/ld-avr/relax-insn-at-range-boundary.d: New test. + * ld/testsuite/ld-avr/relax-insn-at-range-boundary.s: New test. + +2019-05-21 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com> + PR ld/24564 * testsuite/ld-avr/wraparound-range-boundary.d: New test. * testsuite/ld-avr/wraparound-range-boundary.s: New test. diff --git a/ld/testsuite/ld-avr/relax-insn-at-range-boundary.d b/ld/testsuite/ld-avr/relax-insn-at-range-boundary.d new file mode 100644 index 0000000..6183896 --- /dev/null +++ b/ld/testsuite/ld-avr/relax-insn-at-range-boundary.d @@ -0,0 +1,17 @@ +#name: AVR relaxation, jump to symbol at ends of pc-relative range boundary +#as: -mlink-relax -mavr51 +#ld: --relax -mavr51 +#source: relax-insn-at-range-boundary.s +#objdump: -d +#target: avr-*-* + +#... +00000000.* + ... + ffc: 00 00 nop + ffe: 00 c8 rjmp .-4096 ; 0x0 .* + 1000: ff c7 rjmp .+4094 ; 0x2000 <forward_target> + ... + +00002000 <forward_target>: +#... diff --git a/ld/testsuite/ld-avr/relax-insn-at-range-boundary.s b/ld/testsuite/ld-avr/relax-insn-at-range-boundary.s new file mode 100644 index 0000000..4d710df --- /dev/null +++ b/ld/testsuite/ld-avr/relax-insn-at-range-boundary.s @@ -0,0 +1,11 @@ +.section ".text", "ax",@progbits +.global main +main: +backward_target: ; Exactly -4094 bytes from jmp + .ds.b 4094, 0 + jmp backward_target + jmp forward_target + .ds.b 4094, 0 +forward_target: ; Exactly 4098 bytes before relax, 4096 bytes after relax + nop + |