diff options
Diffstat (limited to 'lld/ELF/Target.cpp')
-rw-r--r-- | lld/ELF/Target.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 0eab75c959c..024e0cfec27 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -91,18 +91,16 @@ TargetInfo *getTarget() { } template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) { + if (!Out::bufferStart) + return {}; + for (InputSectionBase *d : inputSections) { auto *isec = cast<InputSection>(d); if (!isec->getParent()) continue; uint8_t *isecLoc = Out::bufferStart + isec->getParent()->offset + isec->outSecOff; - if (isecLoc > loc) - continue; - // isecLoc might be nullptr here, with isec->getSize() being non-zero. - // Adding these two together is not defined in C++. - if (loc < reinterpret_cast<uint8_t *>( - reinterpret_cast<std::uintptr_t>(isecLoc) + isec->getSize())) + if (isecLoc <= loc && loc < isecLoc + isec->getSize()) return {isec, isec->template getLocation<ELFT>(loc - isecLoc) + ": "}; } return {}; |