[PATCH] D158708: [JITLink][PowerPC] Fix incorrect assertion of addend for R_PPC64_REL24
Kai Luo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 23:52:25 PDT 2023
lkail created this revision.
Herald added subscribers: shchenz, kbarton, hiraditya, nemanjai.
Herald added a project: All.
lkail requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
There is case that R_PPC64_REL24 with non-zero addend. The assertion is incorrectly triggered in such situation.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158708
Files:
llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
Index: llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
===================================================================
--- llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
+++ llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp
@@ -346,9 +346,13 @@
break;
case ELF::R_PPC64_REL24:
Kind = ppc64::RequestCall;
- assert(Addend == 0 && "Addend is expected to be 0 for a function call");
- // We assume branching to local entry, will reverse the addend if not.
- Addend = ELF::decodePPC64LocalEntryOffset((*ObjSymbol)->st_other);
+ // Determining a target is external or not is deferred in PostPrunePass.
+ // We assume branching to local entry by default, since in PostPrunePass,
+ // we don't have any context to determine LocalEntryOffset. If it finally
+ // turns out to be an external call, we'll have a stub for the external
+ // target, the target of this edge will be the stub and its addend will be
+ // set 0.
+ Addend += ELF::decodePPC64LocalEntryOffset((*ObjSymbol)->st_other);
break;
case ELF::R_PPC64_REL64:
Kind = ppc64::Delta64;
Index: llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
+++ llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h
@@ -205,8 +205,6 @@
E.setKind(ppc64::CallBranchDeltaRestoreTOC);
this->StubKind = LongBranchSaveR2;
E.setTarget(this->getEntryForTarget(G, E.getTarget()));
- // We previously set branching to local entry. Now reverse that
- // operation.
E.setAddend(0);
} else
// TODO: There are cases a local function call need a call stub.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158708.553005.patch
Type: text/x-patch
Size: 1749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/e7fc760a/attachment-0001.bin>
More information about the llvm-commits
mailing list