[llvm] [RuntimeDyld] Add LoongArch support (PR #114741)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 04:49:51 PST 2024
================
@@ -645,6 +645,203 @@ void RuntimeDyldELF::resolveARMRelocation(const SectionEntry &Section,
}
}
+bool RuntimeDyldELF::resolveLoongArch64ShortBranch(
+ unsigned SectionID, relocation_iterator RelI,
+ const RelocationValueRef &Value) {
+ uint64_t Address;
+ if (Value.SymbolName) {
+ auto Loc = GlobalSymbolTable.find(Value.SymbolName);
+ // Don't create direct branch for external symbols.
+ if (Loc == GlobalSymbolTable.end())
+ return false;
+ const auto &SymInfo = Loc->second;
+ Address =
+ uint64_t(Sections[SymInfo.getSectionID()].getLoadAddressWithOffset(
+ SymInfo.getOffset()));
+ } else {
+ Address = uint64_t(Sections[Value.SectionID].getLoadAddress());
+ }
+ uint64_t Offset = RelI->getOffset();
+ uint64_t SourceAddress = Sections[SectionID].getLoadAddressWithOffset(Offset);
+ if (!isInt<28>(Address + Value.Addend - SourceAddress))
+ return false;
+ resolveRelocation(Sections[SectionID], Offset, Address, RelI->getType(),
+ Value.Addend);
+ return true;
+}
+
+void RuntimeDyldELF::resolveLoongArch64Branch(unsigned SectionID,
+ const RelocationValueRef &Value,
+ relocation_iterator RelI,
+ StubMap &Stubs) {
+ LLVM_DEBUG(dbgs() << "\t\tThis is an LoongArch64 branch relocation.\n");
+ SectionEntry &Section = Sections[SectionID];
+ uint64_t Offset = RelI->getOffset();
+ unsigned RelType = RelI->getType();
+ // Look for an existing stub.
+ StubMap::const_iterator i = Stubs.find(Value);
+ if (i != Stubs.end()) {
----------------
wangleiat wrote:
Thank you very much; I will revise it to a clearer logic.
https://github.com/llvm/llvm-project/pull/114741
More information about the llvm-commits
mailing list