Fix PR 24571 - Relaxation does not shorten jmp or call to target at pc-relative...
authorSenthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
Thu, 16 May 2019 06:42:33 +0000 (12:12 +0530)
committerSenthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
Tue, 21 May 2019 07:18:06 +0000 (12:48 +0530)
commit7622049e0bef81fab900860400838bc977449892
tree31038b59df87994bae534de94b70c8c7d7441634
parent338ba75534fbfeb64d7009f29a89f25826a1f4d2
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.
bfd/ChangeLog
bfd/elf32-avr.c
ld/ChangeLog
ld/testsuite/ld-avr/relax-insn-at-range-boundary.d [new file with mode: 0644]
ld/testsuite/ld-avr/relax-insn-at-range-boundary.s [new file with mode: 0644]