diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-06-25 22:49:13 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-06-25 22:49:13 +0000 |
commit | af5ca95730b887a443bc24c426ca5455b75fccba (patch) | |
tree | 3fb250fbb7847be34739a0ed8a66f189812a7864 /libcxxabi/src | |
parent | 262510a4acd715160c5055e63568ca7476d6ac3f (diff) | |
download | bcm5719-llvm-af5ca95730b887a443bc24c426ca5455b75fccba.tar.gz bcm5719-llvm-af5ca95730b887a443bc24c426ca5455b75fccba.zip |
Start landing support for ARM EHABI unwinding.
The new code will be behind a LIBCXXABI_ARM_EHABI define (so that platforms
that don't want it can continue using e.g. SJLJ). This commit mostly just
adds the LIBCXXABI_ARM_EHABI define.
llvm-svn: 211739
Diffstat (limited to 'libcxxabi/src')
-rw-r--r-- | libcxxabi/src/Unwind/AddressSpace.hpp | 34 | ||||
-rw-r--r-- | libcxxabi/src/Unwind/config.h | 28 |
2 files changed, 48 insertions, 14 deletions
diff --git a/libcxxabi/src/Unwind/AddressSpace.hpp b/libcxxabi/src/Unwind/AddressSpace.hpp index 283f14e4c43..2682ec4169b 100644 --- a/libcxxabi/src/Unwind/AddressSpace.hpp +++ b/libcxxabi/src/Unwind/AddressSpace.hpp @@ -31,11 +31,27 @@ namespace libunwind { #include "dwarf2.h" #include "Registers.hpp" +#if LIBCXXABI_ARM_EHABI +#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 // LIBCXXABI_ARM_EHABI + namespace libunwind { /// Used by findUnwindSections() to return info about needed sections. struct UnwindInfoSections { - uintptr_t dso_base; +#if _LIBUNWIND_SUPPORT_DWARF_UNWIND || _LIBUNWIND_SUPPORT_DWARF_INDEX || \ + _LIBUNWIND_SUPPORT_COMPACT_UNWIND + // No dso_base for ARM EHABI. + uintptr_t dso_base; +#endif #if _LIBUNWIND_SUPPORT_DWARF_UNWIND uintptr_t dwarf_section; uintptr_t dwarf_section_length; @@ -48,6 +64,10 @@ struct UnwindInfoSections { uintptr_t compact_unwind_section; uintptr_t compact_unwind_section_length; #endif +#if LIBCXXABI_ARM_EHABI + uintptr_t arm_section; + uintptr_t arm_section_length; +#endif }; @@ -303,9 +323,15 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, info.compact_unwind_section_length = dyldInfo.compact_unwind_section_length; return true; } -#else - // TO DO - +#elif LIBCXXABI_ARM_EHABI + 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 7d7e6bf0b7c..638dab24585 100644 --- a/libcxxabi/src/Unwind/config.h +++ b/libcxxabi/src/Unwind/config.h @@ -57,16 +57,24 @@ #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 + // ARM EHABI. + 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 #endif |