mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
[JITLink][PowerPC] Fix incorrect assertion of addend for R_PPC64_REL24
There is case that R_PPC64_REL24 with non-zero addend. The assertion is incorrectly triggered in such situation. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D158708
This commit is contained in:
@@ -204,9 +204,11 @@ public:
|
||||
if (isExternal) {
|
||||
E.setKind(ppc64::CallBranchDeltaRestoreTOC);
|
||||
this->StubKind = LongBranchSaveR2;
|
||||
// FIXME: We assume the addend to the external target is zero. It's
|
||||
// quite unusual that the addend of an external target to be non-zero as
|
||||
// if we have known the layout of the external object.
|
||||
E.setTarget(this->getEntryForTarget(G, E.getTarget()));
|
||||
// We previously set branching to local entry. Now reverse that
|
||||
// operation.
|
||||
// Addend to the stub is zero.
|
||||
E.setAddend(0);
|
||||
} else
|
||||
// TODO: There are cases a local function call need a call stub.
|
||||
|
||||
@@ -346,9 +346,13 @@ private:
|
||||
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;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# REQUIRES: asserts
|
||||
# RUN: yaml2obj %S/Inputs/rel24-non-zero-addend.yaml -o %t.o
|
||||
# RUN: not --crash llvm-jitlink -noexec %t.o 2>&1 | FileCheck %s
|
||||
# CHECK: Addend == 0 && "Addend is expected to be 0 for a function call"
|
||||
#
|
||||
# RUN: llvm-jitlink -noexec %t.o 2>&1
|
||||
# The object is generated from llvm/test/ExecutionEngine/MCJIT/test-global-ctors.ll,
|
||||
# containing an R_PPC64_REL24 whose addend is not zero.
|
||||
|
||||
Reference in New Issue
Block a user