@@ -662,7 +662,16 @@ bool RuntimeDyldELF::resolveLoongArch64ShortBranch(
662662 }
663663 uint64_t Offset = RelI->getOffset ();
664664 uint64_t SourceAddress = Sections[SectionID].getLoadAddressWithOffset (Offset);
665- if (!isInt<28 >(Address + Value.Addend - SourceAddress))
665+ // Normal call
666+ if (RelI->getType () == ELF::R_LARCH_B26) {
667+ if (!isInt<28 >(Address + Value.Addend - SourceAddress))
668+ return false ;
669+ resolveRelocation (Sections[SectionID], Offset, Address, RelI->getType (),
670+ Value.Addend );
671+ return true ;
672+ }
673+ // Medium call: R_LARCH_CALL36
674+ if (!isInt<38 >(Address + Value.Addend - SourceAddress))
666675 return false ;
667676 resolveRelocation (Sections[SectionID], Offset, Address, RelI->getType (),
668677 Value.Addend );
@@ -1743,7 +1752,8 @@ RuntimeDyldELF::processRelocationRef(
17431752 processSimpleRelocation (SectionID, Offset, RelType, Value);
17441753 }
17451754 } else if (Arch == Triple::loongarch64) {
1746- if (RelType == ELF::R_LARCH_B26 && MemMgr.allowStubAllocation ()) {
1755+ if ((RelType == ELF::R_LARCH_B26 || RelType == ELF::R_LARCH_CALL36) &&
1756+ MemMgr.allowStubAllocation ()) {
17471757 resolveLoongArch64Branch (SectionID, Value, RelI, Stubs);
17481758 } else if (RelType == ELF::R_LARCH_GOT_PC_HI20 ||
17491759 RelType == ELF::R_LARCH_GOT_PC_LO12) {
0 commit comments