Skip to content

[rebranch] Various JIT failure workarounds #9135

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 2 commits into from
Aug 20, 2024
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
22 changes: 9 additions & 13 deletions llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,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 @@ -528,18 +521,21 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySymbols() {
return make_error<JITLinkError>(std::move(ErrMsg));
}

// Truncate symbol if it would overflow -- ELF size fields can't be
// trusted.
uint64_t Size =
std::min(static_cast<uint64_t>(Sym.st_size), B->getSize() - Offset);

// In RISCV, temporary symbols (Used to generate dwarf, eh_frame
// sections...) will appear in object code's symbol table, and LLVM does
// not use names on these temporary symbols (RISCV gnu toolchain uses
// names on these temporary symbols). If the symbol is unnamed, add an
// 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