[lld] [LLD][RISCV][Zicfilp] Generate unlabeled landing pad-style PLT (PR #145461)
Jessica Clarke via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 27 13:47:45 PDT 2026
================
----------------
jrtc27 wrote:
```suggestion
// If using lpad:
//
// lpad 0
// 1: auipc t2, %pcrel_hi(f at .got.plt)
// l[wd] t2, %pcrel_lo(1b)(t3)
// jalr t1, t2
//
// If not using lpad:
//
// 1: auipc t3, %pcrel_hi(f at .got.plt)
// l[wd] t3, %pcrel_lo(1b)(t3)
// jalr t1, t3
// nop
bool lpad = ctx.arg.andFeatures & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED;
uint32_t auipcOffset = lpad * 4;
uint32_t offset = sym.getGotPltVA(ctx) - pltEntryAddr - auipcOffset;
uint32_t rd = lpad ? X_T2 : X_T3;
if (lpad)
write32le(buf + 0, utype(AUIPC, X_X0, 0)); // lpad 0
write32le(buf + 0 + auipcOffset, utype(AUIPC, rd, hi20(offset)));
write32le(buf + 4 + auipcOffset, itype(ctx.arg.is64 ? LD : LW, rd, rd, lo12(offset)));
write32le(buf + 8 + auipcOffset, itype(JALR, X_T1, rd, 0));
if (!lpad)
write32le(buf + 12, itype(ADDI, 0, 0, 0));
```
Don't know if something like that's better or not to be honest.
https://github.com/llvm/llvm-project/pull/145461
More information about the llvm-commits
mailing list