LoongArch: Fix instruction immediate bug caused by sign-extend
authormengqinggang <mengqinggang@loongson.cn>
Sat, 15 Jul 2023 09:17:12 +0000 (17:17 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Mon, 24 Jul 2023 03:22:42 +0000 (11:22 +0800)
commit378535f277b31e28f74cc65df6876c616beb04b4
tree1e69f4f0e61732e392ec683efe59fb1ab0d30046
parent5cbe549257b0aed1b615714e74bb6a3f066f3253
LoongArch: Fix instruction immediate bug caused by sign-extend

For extreme code mode, the instruction sequences is
    pcalau12i $t0, hi20
    addi.d $t1, $zero, lo12
    lu32i.d $t1, lo20
    lu52i.d $t1, hi12
    add.d $t1, $t0, $t1

If lo12 > 0x7ff, hi20 need to add 0x1, lo20 need to sub 0x1.
If hi20 > 0x7ffff, lo20 need to add 0x1.

bfd/ChangeLog:

* elfnn-loongarch.c (RELOCATE_CALC_PC32_HI20): Redefined.
(RELOCATE_CALC_PC64_HI32): Redefined.
bfd/elfnn-loongarch.c