git: bcbcd7303009 - main - Merge commit cbf48349e3e1 from llvm-project (by Jessica Clarke):
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 27 Jul 2026 16:56:02 UTC
The branch main has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=bcbcd7303009344dc1051e4601284620bca29be8
commit bcbcd7303009344dc1051e4601284620bca29be8
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2026-07-27 16:53:53 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2026-07-27 16:53:53 +0000
Merge commit cbf48349e3e1 from llvm-project (by Jessica Clarke):
[NFC][ELF][PPC64] Pass address not offset to writePPC64LoadAndBranch (#212275)
Every caller currently subtracts the TOC base in its argument, so move
that into common code inside writePPC64LoadAndBranch. This will also
allow a different computation to be used in some cases in a future
commit.
Note that offset is now unsigned not signed; even previously, all
arguments were uint64_t, and all uses are unsigned, so making it signed
doesn't make much sense.
MFC after: 1 week
---
contrib/llvm-project/lld/ELF/Arch/PPC64.cpp | 3 +--
contrib/llvm-project/lld/ELF/Thunks.cpp | 20 +++++++++-----------
contrib/llvm-project/lld/ELF/Thunks.h | 2 +-
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/contrib/llvm-project/lld/ELF/Arch/PPC64.cpp b/contrib/llvm-project/lld/ELF/Arch/PPC64.cpp
index 3cd4a6294e2a..8e85cfab8a63 100644
--- a/contrib/llvm-project/lld/ELF/Arch/PPC64.cpp
+++ b/contrib/llvm-project/lld/ELF/Arch/PPC64.cpp
@@ -1168,8 +1168,7 @@ void PPC64::writePlt(uint8_t *buf, const Symbol &sym,
void PPC64::writeIplt(uint8_t *buf, const Symbol &sym,
uint64_t /*pltEntryAddr*/) const {
- writePPC64LoadAndBranch(ctx, buf,
- sym.getGotPltVA(ctx) - getPPC64TocBase(ctx));
+ writePPC64LoadAndBranch(ctx, buf, sym.getGotPltVA(ctx));
}
static std::pair<RelType, uint64_t> toAddr16Rel(RelType type, uint64_t val) {
diff --git a/contrib/llvm-project/lld/ELF/Thunks.cpp b/contrib/llvm-project/lld/ELF/Thunks.cpp
index 65d0f094c43c..45b9ab9530e0 100644
--- a/contrib/llvm-project/lld/ELF/Thunks.cpp
+++ b/contrib/llvm-project/lld/ELF/Thunks.cpp
@@ -1402,7 +1402,8 @@ void PPC32LongThunk::writeTo(uint8_t *buf) {
write32(ctx, buf + 4, 0x4e800420); // bctr
}
-void elf::writePPC64LoadAndBranch(Ctx &ctx, uint8_t *buf, int64_t offset) {
+void elf::writePPC64LoadAndBranch(Ctx &ctx, uint8_t *buf, uint64_t addr) {
+ uint64_t offset = addr - getPPC64TocBase(ctx);
uint16_t offHa = (offset + 0x8000) >> 16;
uint16_t offLo = offset & 0xffff;
@@ -1413,10 +1414,9 @@ void elf::writePPC64LoadAndBranch(Ctx &ctx, uint8_t *buf, int64_t offset) {
}
void PPC64PltCallStub::writeTo(uint8_t *buf) {
- int64_t offset = destination.getGotPltVA(ctx) - getPPC64TocBase(ctx);
// Save the TOC pointer to the save-slot reserved in the call frame.
write32(ctx, buf + 0, 0xf8410018); // std r2,24(r1)
- writePPC64LoadAndBranch(ctx, buf + 4, offset);
+ writePPC64LoadAndBranch(ctx, buf + 4, destination.getGotPltVA(ctx));
}
void PPC64PltCallStub::addSymbols(ThunkSection &isec) {
@@ -1456,10 +1456,9 @@ void PPC64R2SaveStub::writeTo(uint8_t *buf) {
write32(ctx, buf + nextInstOffset + 4, BCTR); // bctr
} else {
ctx.in.ppc64LongBranchTarget->addEntry(&destination, addend);
- const int64_t offsetFromTOC =
- ctx.in.ppc64LongBranchTarget->getEntryVA(&destination, addend) -
- getPPC64TocBase(ctx);
- writePPC64LoadAndBranch(ctx, buf + 4, offsetFromTOC);
+ const uint64_t addr =
+ ctx.in.ppc64LongBranchTarget->getEntryVA(&destination, addend);
+ writePPC64LoadAndBranch(ctx, buf + 4, addr);
}
}
@@ -1519,10 +1518,9 @@ bool PPC64R12SetupStub::isCompatibleWith(const InputSection &isec,
}
void PPC64LongBranchThunk::writeTo(uint8_t *buf) {
- int64_t offset =
- ctx.in.ppc64LongBranchTarget->getEntryVA(&destination, addend) -
- getPPC64TocBase(ctx);
- writePPC64LoadAndBranch(ctx, buf, offset);
+ uint64_t addr =
+ ctx.in.ppc64LongBranchTarget->getEntryVA(&destination, addend);
+ writePPC64LoadAndBranch(ctx, buf, addr);
}
void PPC64LongBranchThunk::addSymbols(ThunkSection &isec) {
diff --git a/contrib/llvm-project/lld/ELF/Thunks.h b/contrib/llvm-project/lld/ELF/Thunks.h
index 446345b8517f..a802827ba407 100644
--- a/contrib/llvm-project/lld/ELF/Thunks.h
+++ b/contrib/llvm-project/lld/ELF/Thunks.h
@@ -85,7 +85,7 @@ std::unique_ptr<Thunk> addLandingPadThunk(Ctx &, Symbol &s, int64_t a);
void writePPC32PltCallStub(Ctx &, uint8_t *buf, uint64_t gotPltVA,
const InputFile *file, int64_t addend);
-void writePPC64LoadAndBranch(Ctx &, uint8_t *buf, int64_t offset);
+void writePPC64LoadAndBranch(Ctx &, uint8_t *buf, uint64_t addr);
} // namespace lld::elf