diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index 28b96c341e3ff..8f7eead02a66c 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -805,7 +805,10 @@ Expected> static readBBAddrMapImpl( return createError("unable to get the linked-to section for " + describe(EF, Sec) + ": " + toString(TextSecOrErr.takeError())); - if (*TextSectionIndex != std::distance(Sections.begin(), *TextSecOrErr)) + assert(*TextSecOrErr >= Sections.begin() && + "Text section pointer outside of bounds"); + if (*TextSectionIndex != + (unsigned)std::distance(Sections.begin(), *TextSecOrErr)) return false; return true; };