[UPSTREAM][libunwind][Android] Fix findUnwindSections for ARM EHABI Bionic am: 2d1e9b81f0 am: 249d6896be am: 1d3fc5d822
am: 4399044c4f
Change-Id: Iebdc5aa7304bb59967a1450fa150dc9c952131ee
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp
index fb370ad..18e7228 100644
--- a/src/AddressSpace.hpp
+++ b/src/AddressSpace.hpp
@@ -29,6 +29,13 @@
#include <dlfcn.h>
#endif
+#if defined(_LIBUNWIND_ARM_EHABI)
+struct EHABIIndexEntry {
+ uint32_t functionOffset;
+ uint32_t data;
+};
+#endif
+
#ifdef __APPLE__
#include <mach-o/getsect.h>
namespace libunwind {
@@ -459,12 +466,13 @@
(void)targetAddr;
(void)info;
return true;
-#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \
- (__ANDROID_API__ < 21)
+#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__)
+ // For ARM EHABI, Bionic didn't implement dl_iterate_phdr until API 21. After
+ // API 21, dl_iterate_phdr exists, but dl_unwind_find_exidx is much faster.
int length = 0;
info.arm_section =
(uintptr_t)dl_unwind_find_exidx((_Unwind_Ptr)targetAddr, &length);
- info.arm_section_length = (uintptr_t)length;
+ info.arm_section_length = (uintptr_t)length * sizeof(EHABIIndexEntry);
if (info.arm_section && info.arm_section_length)
return true;
#elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
diff --git a/src/UnwindCursor.hpp b/src/UnwindCursor.hpp
index 836de38..e2de6d5 100644
--- a/src/UnwindCursor.hpp
+++ b/src/UnwindCursor.hpp
@@ -1222,11 +1222,6 @@
#endif // defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
#if defined(_LIBUNWIND_ARM_EHABI)
-struct EHABIIndexEntry {
- uint32_t functionOffset;
- uint32_t data;
-};
-
template<typename A>
struct EHABISectionIterator {
typedef EHABISectionIterator _Self;