Skip to content
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