[libcxxabi] r196436 - [unwind] remove darwin build dependency on <mach-o/dyld_priv.h>
Nick Kledzik
kledzik at apple.com
Wed Dec 4 16:12:04 PST 2013
Author: kledzik
Date: Wed Dec 4 18:12:03 2013
New Revision: 196436
URL: http://llvm.org/viewvc/llvm-project?rev=196436&view=rev
Log:
[unwind] remove darwin build dependency on <mach-o/dyld_priv.h>
Modified:
libcxxabi/trunk/src/Unwind/AddressSpace.hpp
Modified: libcxxabi/trunk/src/Unwind/AddressSpace.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/AddressSpace.hpp?rev=196436&r1=196435&r2=196436&view=diff
==============================================================================
--- libcxxabi/trunk/src/Unwind/AddressSpace.hpp (original)
+++ libcxxabi/trunk/src/Unwind/AddressSpace.hpp Wed Dec 4 18:12:03 2013
@@ -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 LocalAd
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__
More information about the cfe-commits
mailing list