[lld] [llvm] [LoongArch] Use R_LARCH_ALIGN with section symbol (PR #84741)

Lu Weining via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 06:24:47 PDT 2024


================
@@ -462,7 +462,11 @@ void InputSection::copyRelocations(uint8_t *buf,
         addend += sec->getFile<ELFT>()->mipsGp0;
       }
 
-      if (RelTy::IsRela)
+      if (config->emachine == EM_LOONGARCH && type == R_LARCH_ALIGN)
+        // LoongArch psABI v2.30, the R_LARCH_ALIGN requires symbol index.
+        // If it use the section symbol, the addend should not be changed.
+        p->r_addend = addend;
+      else if (RelTy::IsRela)
----------------
SixWeining wrote:

How about:
```
  if (RelTy::IsRela && !(config->emachine == EM_LOONGARCH && type == R_LARCH_ALIGN))
    ....
```

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


More information about the llvm-commits mailing list