Skip to content

Commit d6791fb

Browse files
author
Kai Luo
committed
[JITLink][PowerPC] Fix relocations in stubs for ppc64 big-endian target
Offset and addend are fixed for big-endian stubs. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D157257
1 parent 8a31f7d commit d6791fb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,29 @@ inline PLTCallStubInfo pickStub(PLTCallStubKind StubKind) {
8080
isLE ? PointerJumpStubContent_little : PointerJumpStubContent_big;
8181
// Skip save r2.
8282
Content = Content.slice(4);
83+
size_t Offset = isLE ? 0 : 2;
8384
return PLTCallStubInfo{
8485
Content,
85-
{{TOCDelta16HA, 0, 0}, {TOCDelta16LO, 4, 0}},
86+
{{TOCDelta16HA, Offset, 0}, {TOCDelta16LO, Offset + 4, 0}},
8687
};
8788
}
8889
case LongBranchSaveR2: {
8990
ArrayRef<char> Content =
9091
isLE ? PointerJumpStubContent_little : PointerJumpStubContent_big;
92+
size_t Offset = isLE ? 4 : 6;
9193
return PLTCallStubInfo{
9294
Content,
93-
{{TOCDelta16HA, 4, 0}, {TOCDelta16LO, 8, 0}},
95+
{{TOCDelta16HA, Offset, 0}, {TOCDelta16LO, Offset + 4, 0}},
9496
};
9597
}
9698
case LongBranchNoTOC: {
9799
ArrayRef<char> Content = isLE ? PointerJumpStubNoTOCContent_little
98100
: PointerJumpStubNoTOCContent_big;
101+
size_t Offset = isLE ? 16 : 18;
102+
Edge::AddendT Addend = isLE ? 8 : 10;
99103
return PLTCallStubInfo{
100104
Content,
101-
{{Delta16HA, 16, 8}, {Delta16LO, 20, 12}},
105+
{{Delta16HA, Offset, Addend}, {Delta16LO, Offset + 4, Addend + 4}},
102106
};
103107
}
104108
}

llvm/test/ExecutionEngine/JITLink/ppc64/ELF_ppc64_relocations.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# RUN: --check %s %t/elf_reloc.o
99
# RUN: llvm-mc --triple=powerpc64-unknown-linux-gnu --filetype=obj -o \
1010
# RUN: %t/elf_reloc.o %s
11-
# RUN: not llvm-jitlink --noexec \
11+
# RUN: llvm-jitlink --noexec \
1212
# RUN: --abs external_data=0xdeadbeef \
1313
# RUN: --abs external_func=0xcafef00d \
1414
# RUN: --abs external_func_notoc=0x88880000 \

0 commit comments

Comments
 (0)