Hi Nick, Can you please take a look at this patch? With this, we define an UnwindInfoSections for ARM EHABI and are able to populate it.
We'll start making use of this in future patches, as Albert laid out here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140526/106670.html This patch builds and passes tests on Mac. Thanks, Dana
commit 36646ec181901973b495634c06c2db3933b9c7a2 Author: Dana Jansens <[email protected]> Date: Mon Jun 2 08:39:12 2014 -0400 unwind: Add support for ARM EHABI in LocalAddressSpace. When building on non-apple, define _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND. Then use this define to make LocalAddressSpace::findUnwindSections() find the exidx section, and store that in the UnwindInfoSections. Since ARM EHABI does not need a dso_base variable in the UnwindInfoSections, move it into each of the other platform blocks to avoid it when implementing ARM EHABI. Change-Id: I525e5a0b917a036511eb59a0631af7fb663d6b66 diff --git a/sources/cxx-stl/llvm-libc++abi/libcxxabi/src/Unwind/AddressSpace.hpp b/libcxxabi/src/Unwind/AddressSpace.hpp index 283f14e..8873094 100644 --- a/libcxxabi/src/Unwind/AddressSpace.hpp +++ b/libcxxabi/src/Unwind/AddressSpace.hpp @@ -19,6 +19,18 @@ #include <string.h> #include <dlfcn.h> +#if _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND +#if __LINUX__ + // Emulate the BSD dl_unwind_find_exidx API when on a GNU libdl system. + typedef long unsigned int *_Unwind_Ptr; + extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr targetAddr, int *length); + _Unwind_Ptr (*dl_unwind_find_exidx)(_Unwind_Ptr targetAddr, int *length) = + __gnu_Unwind_Find_exidx; +#else + #include <link.h> +#endif +#endif // _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND + #if __APPLE__ #include <mach-o/getsect.h> namespace libunwind { @@ -35,19 +47,26 @@ namespace libunwind { /// Used by findUnwindSections() to return info about needed sections. struct UnwindInfoSections { - uintptr_t dso_base; #if _LIBUNWIND_SUPPORT_DWARF_UNWIND + uintptr_t dso_base; uintptr_t dwarf_section; uintptr_t dwarf_section_length; #endif #if _LIBUNWIND_SUPPORT_DWARF_INDEX + uintptr_t dso_base; uintptr_t dwarf_index_section; uintptr_t dwarf_index_section_length; #endif #if _LIBUNWIND_SUPPORT_COMPACT_UNWIND + uintptr_t dso_base; uintptr_t compact_unwind_section; uintptr_t compact_unwind_section_length; #endif +#if _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND + // No dso_base for ARM EHABI. + uintptr_t arm_section; + uintptr_t arm_section_length; +#endif }; @@ -303,9 +322,15 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, info.compact_unwind_section_length = dyldInfo.compact_unwind_section_length; return true; } -#else - // TO DO - +#elif _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND + int length = 0; + info.arm_section = (uintptr_t) dl_unwind_find_exidx( + (_Unwind_Ptr) targetAddr, &length); + info.arm_section_length = length; + _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %X length %x\n", + info.arm_section, info.arm_section_length); + if (info.arm_section && info.arm_section_length) + return true; #endif return false; diff --git a/libcxxabi/src/Unwind/config.h b/libcxxabi/src/Unwind/config.h index 7d7e6bf..fb9aaad 100644 --- a/libcxxabi/src/Unwind/config.h +++ b/libcxxabi/src/Unwind/config.h @@ -47,26 +47,36 @@ #define _LIBUNWIND_ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg) #if FOR_DYLD - #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 - #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0 - #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 + #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0 + #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + #define _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND 0 #else - #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 - #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 - #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1 + #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1 + #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + #define _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND 0 #endif #else - // #define _LIBUNWIND_BUILD_ZERO_COST_APIS - // #define _LIBUNWIND_BUILD_SJLJ_APIS - // #define _LIBUNWIND_SUPPORT_FRAME_APIS - // #define _LIBUNWIND_EXPORT - // #define _LIBUNWIND_HIDDEN - // #define _LIBUNWIND_LOG() - // #define _LIBUNWIND_ABORT() - // #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND - // #define _LIBUNWIND_SUPPORT_DWARF_UNWIND - // #define _LIBUNWIND_SUPPORT_DWARF_INDEX + static inline void assert_rtn(const char* func, const char* file, int line, const char* msg) __attribute__ ((noreturn)); + static inline void assert_rtn(const char* func, const char* file, int line, const char* msg) { + fprintf(stderr, "libunwind: %s %s:%d - %s\n", func, file, line, msg); + assert(false); + abort(); + } + #define _LIBUNWIND_BUILD_ZERO_COST_APIS (__i386__ || __x86_64__ || __arm64__ || __arm__) + #define _LIBUNWIND_BUILD_SJLJ_APIS 0 + #define _LIBUNWIND_SUPPORT_FRAME_APIS (__i386__ || __x86_64__) + #define _LIBUNWIND_EXPORT __attribute__((visibility("default"))) + #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden"))) + #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__) + #define _LIBUNWIND_ABORT(msg) assert_rtn(__func__, __FILE__, __LINE__, msg) + + #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0 + #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0 + #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0 + #define _LIBUNWIND_SUPPORT_ARM_EHABI_UNWIND 1 #endif
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
