[llvm] [BOLT][RISCV]Fix handling of GOT relocation pairs (PR #149658)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 19 09:31:00 PDT 2025
dinyy wrote:
before fix:
```
00000000: auipc t0, %pcrel_hi(__BOLT_got_zero+9880) # Label: .Ltmp16
00000004: auipc t1, %pcrel_hi(__BOLT_got_zero+8140) # Label: .Ltmp17
00000008: ld t0, %pcrel_lo(.Ltmp16)(t0)
0000000c: ld t1, %pcrel_lo(.Ltmp17)(t1)
```
after fix:
```
00000000: auipc t0, %pcrel_hi(__BOLT_got_zero+8136) # Label: .Ltmp16
00000004: ld t0, %pcrel_lo(.Ltmp16)(t0)
00000008: auipc t1, %pcrel_hi(__BOLT_got_zero+8144) # Label: .Ltmp17
0000000c: ld t1, %pcrel_lo(.Ltmp17)(t1)
```
after fix , we could get the correct __BOLT_got_zero + offset .
And because this note in `llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp`:
```
case R_RISCV_PCREL_LO12_I: {
// FIXME: We assume that R_RISCV_PCREL_HI20 is present in object code and
// pairs with current relocation R_RISCV_PCREL_LO12_I. So here may need a
// check.
```
so move auipc instruction to make auipc and its corresponding ld are adjacent.
https://github.com/llvm/llvm-project/pull/149658
More information about the llvm-commits
mailing list