LoongArch: Do not relax pcalau12i+ld.d when there is overflow
commit77bcfb741cbec8cadec7a0d450a32c8a5b161f23
authorLulu Cai <cailulu@loongson.cn>
Tue, 5 Nov 2024 08:21:28 +0000 (5 16:21 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Tue, 19 Nov 2024 01:42:23 +0000 (19 09:42 +0800)
tree2c340a41d66881cf10c0b053c111124be4d4adb3
parent0073bda2108b9d9b71a687a9fc17a3f5b455528f
LoongArch: Do not relax pcalau12i+ld.d when there is overflow

There is no overflow check for the relaxation of pcalau12i+ld.d =>
pcalau12i+addi.d. For instruction sequences that can be relaxed,
they are directly relaxed to pcalau12i+addi.d. However, when the
relative distance between the symbol and the pc exceeds the 32-bit
range, the symbol value cannot be obtained correctly.

Adds an overflow check for the relaxation of pcalau12i+ld.d.
If it is found that the relaxation will overflow, it will not
be relaxed.
bfd/elfnn-loongarch.c
ld/testsuite/ld-loongarch-elf/check_got_relax.d [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/check_got_relax.s [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/check_relax_got.ld [new file with mode: 0644]
ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp