diff options
author | Nick Kledzik <kledzik@apple.com> | 2013-12-05 00:12:03 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2013-12-05 00:12:03 +0000 |
commit | 034e79a395bf7815fd94ad81d40609aa52f2f34c (patch) | |
tree | ce98b6dd4f36bf56837e1cf081c1808c35a3161a /src | |
parent | c22004f1433b5cdd93403e1a048de21566604cd6 (diff) | |
download | libcxxabi_35a-034e79a395bf7815fd94ad81d40609aa52f2f34c.tar.gz |
[unwind] remove darwin build dependency on <mach-o/dyld_priv.h>
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@196436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src')
-rw-r--r-- | src/Unwind/AddressSpace.hpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/Unwind/AddressSpace.hpp b/src/Unwind/AddressSpace.hpp index 9efe8bf..67b0973 100644 --- a/src/Unwind/AddressSpace.hpp +++ b/src/Unwind/AddressSpace.hpp @@ -19,7 +19,7 @@ #include <dlfcn.h> #if __APPLE__ -#include <mach-o/dyld_priv.h> +#include <mach-o/getsect.h> namespace libunwind { bool checkKeyMgrRegisteredFDEs(uintptr_t targetAddr, void *&fde); } @@ -221,6 +221,47 @@ inline LocalAddressSpace::pint_t LocalAddressSpace::getEncodedP(pint_t &addr, return result; } +#if __APPLE__ + struct dyld_unwind_sections + { + const struct mach_header* mh; + const void* dwarf_section; + uintptr_t dwarf_section_length; + const void* compact_unwind_section; + uintptr_t compact_unwind_section_length; + }; + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) \ + && (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1070) + // In 10.7.0 or later, libSystem.dylib implements this function. + extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *); + #else + // In 10.6.x and earlier, we need to implement this functionality. + static inline bool _dyld_find_unwind_sections(void* addr, + dyld_unwind_sections* info) { + // Find mach-o image containing address. + Dl_info dlinfo; + if (!dladdr(addr, &dlinfo)) + return false; + const mach_header *mh = (const mach_header *)dlinfo.dli_saddr; + + // Find dwarf unwind section in that image. + unsigned long size; + const uint8_t *p = getsectiondata(mh, "__TEXT", "__eh_frame", &size); + if (!p) + return false; + + // Fill in return struct. + info->mh = mh; + info->dwarf_section = p; + info->dwarf_section_length = size; + info->compact_unwind_section = 0; + info->compact_unwind_section_length = 0; + + return true; + } + #endif +#endif + inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, UnwindInfoSections &info) { #if __APPLE__ |