[lld] [lld][LoongArch] Relax R_LARCH_PCALA_HI20 and R_LARCH_PCALA_LO12 (PR #112696)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 19:12:11 PST 2024


================
@@ -737,6 +737,17 @@ uint64_t InputSectionBase::getRelocTargetVA(Ctx &ctx, const Relocation &r,
   int64_t a = r.addend;
   switch (r.expr) {
   case R_ABS:
+    // pcalau12i,addi.[wd] => pcaddi
+    // With relaxation applied, the relocation type of the third
+    // reloc entry which corresponds to the addi.[wd] insn is converted
+    // from R_LARCH_PCALA_LO12 to R_LARCH_PCREL20_S2.
+    if (r.type == R_LARCH_PCREL20_S2) {
----------------
ywgrit wrote:

In fact, when I originally wrote the code here, the idea was to align it with the code I just pushed. I.e. adjust RelExpr after relaxation. but we can't get the new RelExpr via the getRelExpr function because functions like fromPlt/toPlt may need to change RelExpr. so we have to manually assign the RelExpr, which is not very standardized in my opinion.

https://github.com/llvm/llvm-project/pull/112696


More information about the llvm-commits mailing list