mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
7622049e0b
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.
12 lines
287 B
ArmAsm
12 lines
287 B
ArmAsm
.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
|
|
|