Skip to content

Commit e545e70

Browse files
authored
Merge pull request #9168 from benlangmuir/fix-jit-harder
[jitlink] Fix cherry-pick in 6267697
2 parents 36d2b5c + d629b38 commit e545e70

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,14 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySymbols() {
505505
TargetFlagsType Flags = makeTargetFlags(Sym);
506506
orc::ExecutorAddrDiff Offset = getRawOffset(Sym, Flags);
507507

508-
if (Offset + Sym.st_size > B->getSize()) {
508+
// Truncate symbol if it would overflow -- ELF size fields can't be
509+
// trusted.
510+
// FIXME: this makes the following error check unreachable, but it's
511+
// left here to reduce merge conflicts.
512+
uint64_t Size =
513+
std::min(static_cast<uint64_t>(Sym.st_size), B->getSize() - Offset);
514+
515+
if (Offset + Size > B->getSize()) {
509516
std::string ErrMsg;
510517
raw_string_ostream ErrStream(ErrMsg);
511518
ErrStream << "In " << G->getName() << ", symbol ";
@@ -521,11 +528,6 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySymbols() {
521528
return make_error<JITLinkError>(std::move(ErrMsg));
522529
}
523530

524-
// Truncate symbol if it would overflow -- ELF size fields can't be
525-
// trusted.
526-
uint64_t Size =
527-
std::min(static_cast<uint64_t>(Sym.st_size), B->getSize() - Offset);
528-
529531
// In RISCV, temporary symbols (Used to generate dwarf, eh_frame
530532
// sections...) will appear in object code's symbol table, and LLVM does
531533
// not use names on these temporary symbols (RISCV gnu toolchain uses

0 commit comments

Comments
 (0)