binutils-gdb/ld/testsuite/ld-loongarch-elf/relax-medium-call-1.s
mengqinggang 6f779908fd LoongArch: Fix relaxation overflow caused by ld -z separate-code
ld -z separate-code let .text and .rodata in two different but read only
segment. If the symbol and pc in two segment, the offset from pc to
symbol need to consider segment alignment.

Add a function 'loongarch_two_sections_in_same_segment' to determine
whether two sections are in the same segment.
2024-05-27 17:41:04 +08:00

43 lines
753 B
ArmAsm

.text
a:
ret
ret
ret
b:
ret
.fill 0x7fffff0
pcaddu18i $ra, %call36(a) # min offset, can relax
jirl $ra, $ra, 0
pcaddu18i $ra, %call36(a) # overflow, not relax
jirl $ra, $ra, 0
pcaddu18i $t0, %call36(b) # min offset, can relax
jirl $zero, $t0, 0
pcaddu18i $t0, %call36(b) # overflow, not relax
jirl $zero, $t0, 0
pcaddu18i $ra, %call36(c) # overflow, not relax
jirl $ra, $ra, 0
pcaddu18i $ra, %call36(c) # max offset, can relax
jirl $ra, $ra, 0
pcaddu18i $t0, %call36(d) # overflow, no relax
jirl $zero, $t0, 0
pcaddu18i $t0, %call36(d) # max offset, can relax
jirl $zero, $t0, 0
.fill 0x7ffffc8
ret
ret
ret
ret
ret
ret
ret
ret
c:
ret
ret
ret
d:
ret