Skip to content

Commit e40baf4

Browse files
committed
Address SixWeining's comments
Created using spr 1.3.5-bogner
1 parent aeb7ab9 commit e40baf4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,18 @@ bool RuntimeDyldELF::resolveLoongArch64ShortBranch(
662662
}
663663
uint64_t Offset = RelI->getOffset();
664664
uint64_t SourceAddress = Sections[SectionID].getLoadAddressWithOffset(Offset);
665+
uint64_t Delta = Address + Value.Addend - SourceAddress;
665666
// Normal call
666667
if (RelI->getType() == ELF::R_LARCH_B26) {
667-
if (!isInt<28>(Address + Value.Addend - SourceAddress))
668+
if (!isInt<28>(Delta))
668669
return false;
669670
resolveRelocation(Sections[SectionID], Offset, Address, RelI->getType(),
670671
Value.Addend);
671672
return true;
672673
}
673674
// Medium call: R_LARCH_CALL36
674-
if (!isInt<38>(Address + Value.Addend - SourceAddress))
675+
// Range: [-128G - 0x20000, +128G - 0x20000)
676+
if (((int64_t)Delta + 0x20000) != llvm::SignExtend64(Delta + 0x20000, 38))
675677
return false;
676678
resolveRelocation(Sections[SectionID], Offset, Address, RelI->getType(),
677679
Value.Addend);

0 commit comments

Comments
 (0)