summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2013-12-05 00:12:03 +0000
committerNick Kledzik <kledzik@apple.com>2013-12-05 00:12:03 +0000
commit87d4a00e9e818688831b070ddb52d50f4a7fa24d (patch)
tree3e5286e47c73c41ffdc839149fedabc5403bb184
parent30bbb214e593c7040b81c01c235417590ba9d475 (diff)
downloadbcm5719-llvm-87d4a00e9e818688831b070ddb52d50f4a7fa24d.tar.gz
bcm5719-llvm-87d4a00e9e818688831b070ddb52d50f4a7fa24d.zip
[unwind] remove darwin build dependency on <mach-o/dyld_priv.h>
llvm-svn: 196436
-rw-r--r--libcxxabi/src/Unwind/AddressSpace.hpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/libcxxabi/src/Unwind/AddressSpace.hpp b/libcxxabi/src/Unwind/AddressSpace.hpp
index 9efe8bf47d6..67b0973de2f 100644
--- a/libcxxabi/src/Unwind/AddressSpace.hpp
+++ b/libcxxabi/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__
OpenPOWER on IntegriCloud