Skip to content

Commit 8b6a35d

Browse files
committed
fix target block offset calculation
1 parent fa0a0f1 commit 8b6a35d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/ExecutionEngine/JITLink/XCOFFLinkGraphBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ Error XCOFFLinkGraphBuilder::processCsectsAndSymbols() {
377377
else
378378
S = Scope::Local;
379379
}
380-
381380

382381
// TODO(HJ): not sure what is Scope::SideEffectsOnly
383382
Linkage L = Weak ? Linkage::Weak : Linkage::Strong;
@@ -430,16 +429,17 @@ Error XCOFFLinkGraphBuilder::processRelocations() {
430429
<< format_hex(B->getAddress().getValue(), 16) << "\n");
431430

432431
// TODO(HJ): correctly map edge kind and figure out if we need addend
433-
auto TargetBlockOffset = S->getAddress() - B->getAddress();
432+
auto TargetBlockOffset = Section.getAddress() + Relocation.getOffset() -
433+
B->getAddress().getValue();
434434
switch (Relocation.getType()) {
435435
case XCOFF::R_POS:
436436
B->addEdge(ppc64::EdgeKind_ppc64::Pointer64, TargetBlockOffset, *S, 0);
437437
break;
438438
default:
439439
SmallString<16> RelocType;
440440
Relocation.getTypeName(RelocType);
441-
return make_error<StringError>("Unsupported Relocation Type: " +
442-
RelocType, std::error_code());
441+
return make_error<StringError>(
442+
"Unsupported Relocation Type: " + RelocType, std::error_code());
443443
}
444444
}
445445
}

0 commit comments

Comments
 (0)