Index: src/UnwindCursor.hpp =================================================================== --- src/UnwindCursor.hpp +++ src/UnwindCursor.hpp @@ -696,6 +696,11 @@ return _Self(addressSpace, sects, sects.arm_section_length / sizeof(EHABIIndexEntry)); } + static _Self last(A& addressSpace, const UnwindInfoSections& sects) { + assert(sects.arm_section_length > 0); + return _Self(addressSpace, sects, + sects.arm_section_length / sizeof(EHABIIndexEntry) - 1); + } EHABISectionIterator(A& addressSpace, const UnwindInfoSections& sects, size_t i) : _i(i), _addressSpace(&addressSpace), _sects(§s) {} @@ -746,13 +751,24 @@ EHABISectionIterator::end(_addressSpace, sects); EHABISectionIterator itNextPC = std::upper_bound(begin, end, pc); - if (itNextPC == begin || itNextPC == end) + if (itNextPC == begin || begin == end) return false; - EHABISectionIterator itThisPC = itNextPC - 1; - pint_t thisPC = itThisPC.functionAddress(); - pint_t nextPC = itNextPC.functionAddress(); - pint_t indexDataAddr = itThisPC.dataAddress(); + pint_t thisPC, nextPC, indexDataAddr; + if (itNextPC == end) { + EHABISectionIterator last = + EHABISectionIterator::last(_addressSpace, sects); + thisPC = last.functionAddress(); + if (pc < thisPC) + return false; + nextPC = ~static_cast(0); + indexDataAddr = last.dataAddress(); + } else { + EHABISectionIterator itThisPC = itNextPC - 1; + thisPC = itThisPC.functionAddress(); + nextPC = itNextPC.functionAddress(); + indexDataAddr = itThisPC.dataAddress(); + } if (indexDataAddr == 0) return false;