Author: Ryan Prichard Date: 2020-09-09T15:43:35-07:00 New Revision: 09d492902f178f60b3ab986360eadde9b5c8d359
URL: https://github.com/llvm/llvm-project/commit/09d492902f178f60b3ab986360eadde9b5c8d359 DIFF: https://github.com/llvm/llvm-project/commit/09d492902f178f60b3ab986360eadde9b5c8d359.diff LOG: [libunwind] Bare-metal DWARF: set dso_base to 0 Previously, DwarfFDECache::findFDE used 0 as a special value meaning "search the entire cache, including dynamically-registered FDEs". Switch this special value to -1, which doesn't make sense as a DSO base. Fixes PR47335. Reviewed By: compnerd, #libunwind Differential Revision: https://reviews.llvm.org/D86748 Added: Modified: libunwind/src/AddressSpace.hpp libunwind/src/UnwindCursor.hpp Removed: ################################################################################ diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index cc298c9bbb83..eccc2153c697 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -518,6 +518,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, return true; } #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) + info.dso_base = 0; // Bare metal is statically linked, so no need to ask the dynamic loader info.dwarf_section_length = (uintptr_t)(&__eh_frame_end - &__eh_frame_start); info.dwarf_section = (uintptr_t)(&__eh_frame_start); diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index e6a36764fc79..206b5e398321 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -81,6 +81,7 @@ template <typename A> class _LIBUNWIND_HIDDEN DwarfFDECache { typedef typename A::pint_t pint_t; public: + static constexpr pint_t kSearchAll = static_cast<pint_t>(-1); static pint_t findFDE(pint_t mh, pint_t pc); static void add(pint_t mh, pint_t ip_start, pint_t ip_end, pint_t fde); static void removeAllIn(pint_t mh); @@ -138,7 +139,7 @@ typename A::pint_t DwarfFDECache<A>::findFDE(pint_t mh, pint_t pc) { pint_t result = 0; _LIBUNWIND_LOG_IF_FALSE(_lock.lock_shared()); for (entry *p = _buffer; p < _bufferUsed; ++p) { - if ((mh == p->mh) || (mh == 0)) { + if ((mh == p->mh) || (mh == kSearchAll)) { if ((p->ip_start <= pc) && (pc < p->ip_end)) { result = p->fde; break; @@ -1945,7 +1946,8 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) { #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) // There is no static unwind info for this pc. Look to see if an FDE was // dynamically registered for it. - pint_t cachedFDE = DwarfFDECache<A>::findFDE(0, pc); + pint_t cachedFDE = DwarfFDECache<A>::findFDE(DwarfFDECache<A>::kSearchAll, + pc); if (cachedFDE != 0) { typename CFI_Parser<A>::FDE_Info fdeInfo; typename CFI_Parser<A>::CIE_Info cieInfo; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits