// that don't help at all.
#elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
-struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
- LocalAddressSpace *addressSpace;
- UnwindInfoSections *sects;
- uintptr_t targetAddr;
-};
-
-int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
- auto cbdata = static_cast<dl_iterate_cb_data *>(data);
- bool found_obj = false;
- bool found_hdr = false;
-
- assert(cbdata);
- assert(cbdata->sects);
-
- if (cbdata->targetAddr < pinfo->dlpi_addr) {
- return false;
- }
-
#if !defined(Elf_Half)
typedef ElfW(Half) Elf_Half;
#endif
typedef ElfW(Addr) Elf_Addr;
#endif
+static Elf_Addr calculateImageBase(struct dl_phdr_info *pinfo) {
Elf_Addr image_base = pinfo->dlpi_addr;
-
#if defined(__ANDROID__) && __ANDROID_API__ < 18
if (image_base == 0) {
// Normally, an image base of 0 indicates a non-PIE executable. On
}
}
#endif
+ return image_base;
+}
- #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
+ LocalAddressSpace *addressSpace;
+ UnwindInfoSections *sects;
+ uintptr_t targetAddr;
+};
+
+#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
#if !defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
- #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
+ #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
#endif
+
+int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
+ auto *cbdata = static_cast<dl_iterate_cb_data *>(data);
+ bool found_obj = false;
+ bool found_hdr = false;
+
+ assert(cbdata);
+ assert(cbdata->sects);
+
+ if (cbdata->targetAddr < pinfo->dlpi_addr)
+ return 0;
+
+ Elf_Addr image_base = calculateImageBase(pinfo);
size_t object_length;
for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {
} else {
return false;
}
- #else // defined(_LIBUNWIND_ARM_EHABI)
+}
+
+#else // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND)
+// Given all the #ifdef's above, the code here is for
+// defined(LIBUNWIND_ARM_EHABI)
+
+int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
+ auto *cbdata = static_cast<dl_iterate_cb_data *>(data);
+ bool found_obj = false;
+ bool found_hdr = false;
+
+ assert(cbdata);
+ assert(cbdata->sects);
+
+ if (cbdata->targetAddr < pinfo->dlpi_addr)
+ return 0;
+
+ Elf_Addr image_base = calculateImageBase(pinfo);
+
for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {
const Elf_Phdr *phdr = &pinfo->dlpi_phdr[i];
if (phdr->p_type == PT_LOAD) {
}
}
return found_obj && found_hdr;
- #endif
}
+#endif // defined(LIBUNWIND_SUPPORT_DWARF_UNWIND)
#endif // defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)