aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgcc/unwind-dw2-fde-dip.c
diff options
context:
space:
mode:
authorJoonas Kylmälä <joonas.kylmala@iki.fi>2018-08-27 18:09:09 (GMT)
committerJoonas Kylmälä <joonas.kylmala@iki.fi>2018-08-27 18:09:09 (GMT)
commit989f332ea4e1ac952625139fbd7c18e8a8b31c8a (patch)
tree28f03931fa1c2148a015d59d9855bf976231101a /gcc-4.9/libgcc/unwind-dw2-fde-dip.c
parentb0c259403b7b74b55fc93f50fd1f2fbae3510ece (diff)
parenta74813a825e49267faa0b2ba45e9cd4bd6ccf4f4 (diff)
downloadtoolchain_gcc-master.zip
toolchain_gcc-master.tar.gz
toolchain_gcc-master.tar.bz2
Merge remote-tracking branch 'aosp/master' into replicant-6.0HEADreplicant-6.0-0004-rc1replicant-6.0master
Diffstat (limited to 'gcc-4.9/libgcc/unwind-dw2-fde-dip.c')
-rw-r--r--gcc-4.9/libgcc/unwind-dw2-fde-dip.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc-4.9/libgcc/unwind-dw2-fde-dip.c b/gcc-4.9/libgcc/unwind-dw2-fde-dip.c
index d6c0521..db98b59 100644
--- a/gcc-4.9/libgcc/unwind-dw2-fde-dip.c
+++ b/gcc-4.9/libgcc/unwind-dw2-fde-dip.c
@@ -183,6 +183,30 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
p_eh_frame_hdr = NULL;
p_dynamic = NULL;
+#if defined(__BIONIC__) && defined(__i386__)
+ if (load_base == 0)
+ {
+ /* A load_base of 0 normally indicates a non-PIE executable. There was a
+ bug in Android's dynamic loader prior to API 18, though, where
+ dl_iterate_phdr incorrectly passed a load_base of 0 for a PIE
+ executable. Work around the bug by recalculating load_base using
+ the PT_PHDR segment. This code path isn't needed for arm32, because
+ arm32 didn't have dl_iterate_phdr until API 21.
+ https://github.com/android-ndk/ndk/issues/505. */
+ size_t i;
+ for (i = 0; i < info->dlpi_phnum; ++i)
+ {
+ const ElfW(Phdr) *fix_phdr = &info->dlpi_phdr[i];
+ if (fix_phdr->p_type == PT_PHDR)
+ {
+ load_base = (_Unwind_Ptr) info->dlpi_phdr -
+ (_Unwind_Ptr) fix_phdr->p_vaddr;
+ break;
+ }
+ }
+ }
+#endif
+
struct frame_hdr_cache_element *prev_cache_entry = NULL,
*last_cache_entry = NULL;