Skip to content

Commit 788acc6

Browse files
committedOct 18, 2019
[libunwind][Android] Fix findUnwindSections for ARM EHABI Bionic
Summary: Fix the arm_section_length count. The meaning of the arm_section_length field changed from num-of-elements to num-of-bytes when the dl_unwind_find_exidx special case was removed (D30306 and D30681). The special case was restored in D39468, but that patch didn't account for the change in arm_section_length's meaning. That patch worked when it was applied to the NDK's fork of libunwind, because it never removed the special case in the first place, and the special case is probably disabled in the Android platform's copy of libunwind, because __ANDROID_API__ is greater than 21. Turn the dl_unwind_find_exidx special case on unconditionally for Bionic. Bionic's dl_unwind_find_exidx is much faster than using dl_iterate_phdr. (e.g. Bionic stores exidx info on an internal soinfo object.) Reviewers: thomasanderson, srhines, danalbert, ed, keith.walker.arm, mclow.lists, compnerd Reviewed By: srhines, danalbert Subscribers: srhines, kristof.beyls, christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68972 llvm-svn: 375275
1 parent 284b6d7 commit 788acc6

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed
 

‎libunwind/src/AddressSpace.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
#endif
3333
#endif
3434

35+
#if defined(_LIBUNWIND_ARM_EHABI)
36+
struct EHABIIndexEntry {
37+
uint32_t functionOffset;
38+
uint32_t data;
39+
};
40+
#endif
41+
3542
#ifdef __APPLE__
3643
#include <mach-o/getsect.h>
3744
namespace libunwind {
@@ -462,12 +469,13 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
462469
(void)targetAddr;
463470
(void)info;
464471
return true;
465-
#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \
466-
(__ANDROID_API__ < 21)
472+
#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__)
473+
// For ARM EHABI, Bionic didn't implement dl_iterate_phdr until API 21. After
474+
// API 21, dl_iterate_phdr exists, but dl_unwind_find_exidx is much faster.
467475
int length = 0;
468476
info.arm_section =
469477
(uintptr_t)dl_unwind_find_exidx((_Unwind_Ptr)targetAddr, &length);
470-
info.arm_section_length = (uintptr_t)length;
478+
info.arm_section_length = (uintptr_t)length * sizeof(EHABIIndexEntry);
471479
if (info.arm_section && info.arm_section_length)
472480
return true;
473481
#elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)

‎libunwind/src/UnwindCursor.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,11 +1222,6 @@ template <typename A, typename R> bool UnwindCursor<A, R>::isSignalFrame() {
12221222
#endif // defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
12231223

12241224
#if defined(_LIBUNWIND_ARM_EHABI)
1225-
struct EHABIIndexEntry {
1226-
uint32_t functionOffset;
1227-
uint32_t data;
1228-
};
1229-
12301225
template<typename A>
12311226
struct EHABISectionIterator {
12321227
typedef EHABISectionIterator _Self;

0 commit comments

Comments
 (0)
Please sign in to comment.