diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-07-26 17:57:50 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-07-26 17:57:50 +0000 |
commit | c68cac090729e2434576272bac18a4e21248d1c5 (patch) | |
tree | 738a6adee9b804992e8da773f0a5c6bd0944be3c /libunwind | |
parent | 819eb09fb21f987f545f445c65aed64c79b60c48 (diff) | |
download | llvm-c68cac090729e2434576272bac18a4e21248d1c5.zip llvm-c68cac090729e2434576272bac18a4e21248d1c5.tar.gz llvm-c68cac090729e2434576272bac18a4e21248d1c5.tar.bz2 |
Merging r308871:
------------------------------------------------------------------------
r308871 | chill | 2017-07-24 02:19:32 -0700 (Mon, 24 Jul 2017) | 17 lines
[libunwind] Handle .ARM.exidx tables without sentinel last entry
UnwindCursor<A, R>::getInfoFromEHABISection assumes the last
entry in the index table never corresponds to a real function.
Indeed, GNU ld always inserts an EXIDX_CANTUNWIND entry,
containing the end of the .text section. However, the EHABI specification
(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf)
does not seem to contain text that requires the presence of a sentinel entry.
In that sense the libunwind implementation isn't compliant with the specification.
This patch makes getInfoFromEHABISection examine the last entry in the index
table if upper_bound returns the end iterator.
Fixes https://bugs.llvm.org/show_bug.cgi?id=31091
Differential revision: https://reviews.llvm.org/D35265
------------------------------------------------------------------------
llvm-svn: 309143
Diffstat (limited to 'libunwind')
-rw-r--r-- | libunwind/src/UnwindCursor.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 5f9cba9..6892f96 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -744,14 +744,21 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection( EHABISectionIterator<A>::begin(_addressSpace, sects); EHABISectionIterator<A> end = EHABISectionIterator<A>::end(_addressSpace, sects); + if (begin == end) + return false; EHABISectionIterator<A> itNextPC = std::upper_bound(begin, end, pc); - if (itNextPC == begin || itNextPC == end) + if (itNextPC == begin) return false; EHABISectionIterator<A> itThisPC = itNextPC - 1; pint_t thisPC = itThisPC.functionAddress(); - pint_t nextPC = itNextPC.functionAddress(); + // If an exception is thrown from a function, corresponding to the last entry + // in the table, we don't really know the function extent and have to choose a + // value for nextPC. Choosing max() will allow the range check during trace to + // succeed. + pint_t nextPC = (itNextPC == end) ? std::numeric_limits<pint_t>::max() + : itNextPC.functionAddress(); pint_t indexDataAddr = itThisPC.dataAddress(); if (indexDataAddr == 0) |