[lld] [lld][LoongArch] Support TLSDESC GD/LD to IE/LE (PR #123715)
Zhaoxin Yang via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 23:29:05 PDT 2025
================
@@ -1088,6 +1193,47 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
tlsIeToLe(loc, rel, val);
}
continue;
+ case RE_LOONGARCH_RELAX_TLS_GD_TO_IE_PAGE_PC:
+ if (rel.type == R_LARCH_TLS_DESC_PC_HI20) {
+ // LoongArch does not support TLSDESC GD/LD to LE/IE optimization in the
+ // extreme code model. In these cases, the relocs are as follows:
+ //
+ // * i -- R_LARCH_TLS_DESC_PC_HI20
+ // * i+1 -- R_LARCH_TLS_DESC_PC_LO12
+ // * i+2 -- R_LARCH_TLS_DESC64_PC_LO20
+ // * i+3 -- R_LARCH_TLS_DESC64_PC_HI12
+ isExtreme =
+ (i + 2 < size && relocs[i + 2].type == R_LARCH_TLS_DESC64_PC_LO20);
+ }
+ [[fallthrough]];
+ case R_RELAX_TLS_GD_TO_IE_ABS:
+ if (isExtreme) {
+ if (rel.type == R_LARCH_TLS_DESC_CALL)
+ continue;
+ rel.expr = getRelExpr(rel.type, *rel.sym, loc);
+ val = SignExtend64(sec.getRelocTargetVA(ctx, rel, secAddr + rel.offset),
+ bits);
+ relocateNoSym(loc, rel.type, val);
+ } else {
+ tlsdescToIe(loc, rel, val);
+ }
+ continue;
+ case R_RELAX_TLS_GD_TO_LE:
+ if (rel.type == R_LARCH_TLS_DESC_PC_HI20) {
+ isExtreme =
+ (i + 2 < size && relocs[i + 2].type == R_LARCH_TLS_DESC64_PC_LO20);
----------------
ylzsx wrote:
Thanks, I will remove it.
https://github.com/llvm/llvm-project/pull/123715
More information about the llvm-commits
mailing list