AddressSpace: fix DWARF based unwinding handling on Android

It is possible that there are no program headers in the module.  Do not
attempt to dereference nullptr as a program header.

llvm-svn: 299591
This commit is contained in:
Saleem Abdulrasool 2017-04-05 21:29:38 +00:00
parent f2dc4362c0
commit 5c18b4406e
1 changed files with 5 additions and 2 deletions

View File

@ -394,8 +394,11 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
size_t object_length;
#if defined(__ANDROID__)
Elf_Addr image_base =
reinterpret_cast<Elf_Addr>(pinfo->dlpi_phdr) -
reinterpret_cast<const Elf_Phdr *>(pinfo->dlpi_phdr)->p_offset;
pinfo->dlpi_phnum
? reinterpret_cast<Elf_Addr>(pinfo->dlpi_phdr) -
reinterpret_cast<const Elf_Phdr *>(pinfo->dlpi_phdr)
->p_offset
: 0;
#endif
for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {