Skip to content

[jitlink] Fix cherry-pick in 6267697a4c #9168

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 1 commit into from
Aug 22, 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
14 changes: 8 additions & 6 deletions llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,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 @@ -521,11 +528,6 @@ 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
Expand Down