Skip to content

[stable/20250601] Various JIT failure workarounds #11005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,7 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySections() {
}
}

if (GraphSec->getMemProt() != Prot) {
std::string ErrMsg;
raw_string_ostream(ErrMsg)
<< "In " << G->getName() << ", section " << *Name
<< " is present more than once with different permissions: "
<< GraphSec->getMemProt() << " vs " << Prot;
return make_error<JITLinkError>(std::move(ErrMsg));
}
GraphSec->setMemProt(GraphSec->getMemProt() | Prot);

Block *B = nullptr;
if (Sec.sh_type != ELF::SHT_NOBITS) {
Expand Down Expand Up @@ -513,7 +506,14 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySymbols() {
TargetFlagsType Flags = makeTargetFlags(Sym);
orc::ExecutorAddrDiff Offset = getRawOffset(Sym, Flags);

if (Offset + Sym.st_size > B->getSize()) {
// Truncate symbol if it would overflow -- ELF size fields can't be
// trusted.
// FIXME: this makes the following error check unreachable, but it's
// left here to reduce merge conflicts.
uint64_t Size =
std::min(static_cast<uint64_t>(Sym.st_size), B->getSize() - Offset);

if (Offset + Size > B->getSize()) {
std::string ErrMsg;
raw_string_ostream ErrStream(ErrMsg);
ErrStream << "In " << G->getName() << ", symbol ";
Expand All @@ -536,11 +536,9 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySymbols() {
// anonymous symbol.
auto &GSym =
Name->empty()
? G->addAnonymousSymbol(*B, Offset, Sym.st_size,
false, false)
: G->addDefinedSymbol(*B, Offset, *Name, Sym.st_size, L,
S, Sym.getType() == ELF::STT_FUNC,
false);
? G->addAnonymousSymbol(*B, Offset, Size, false, false)
: G->addDefinedSymbol(*B, Offset, *Name, Size, L, S,
Sym.getType() == ELF::STT_FUNC, false);

GSym.setTargetFlags(Flags);
setGraphSymbol(SymIndex, GSym);
Expand Down