[PATCH] D137384: [MC][LoongArch] Fix needsRelocateWithSymbol() implementation

Jinyang He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 6 17:10:24 PST 2022


MQ-mengqing added a comment.

In D137384#3907086 <https://reviews.llvm.org/D137384#3907086>, @xry111 wrote:

> Hmm, BFD linker does not support `R_LARCH_GOT_PC_{HI12,LO20}` with a non-zero addend:
>
>   case R_LARCH_GOT_PC_HI20:
>   case R_LARCH_GOT_HI20:
>     /* Calc got offset.  */
>       {
>         unresolved_reloc = false;
>         BFD_ASSERT (rel->r_addend == 0);
>
> Do we need to make a custom implementation which returns false for `R_LARCH_32_PCREL`, `R_LARCH_PCALA*`, and `R_LARCH_B*`, true for others?

The procedure happens before linking. AFAIK, the way of using sec+offset is like RELA while the way of using sym is like REL (, of course it seems the REL is a subset of the RELA).
Relocation symbols that can replace sym with sec+offset are generally local and its offset from sec can be determined at assembly procedure.
If relax which may decrease instructions is not used, the offset would not be changed later. So it is different from the Relocation of RISCV. Replacing the sym with sec+offset effectively reduces the number of syms.
The GOT method is used to access global symbols mostly, can they enter this function?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137384/new/

https://reviews.llvm.org/D137384



More information about the llvm-commits mailing list