aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2016-05-11 20:31:48 -0700
committerChristopher Ferris <cferris@google.com>2016-05-11 20:31:48 -0700
commitc3290dfdd3ef01a52a544b0ee7e37663befb6a3b (patch)
treec5ec20857cf6c2fd47fc3bf7a66058e97be418f6
parentb5ab7580d01cab4d090784f1351d1b3895a60f23 (diff)
downloadlibunwind-c3290dfdd3ef01a52a544b0ee7e37663befb6a3b.tar.gz
Use zero offset when getting bias from memory.nougat-dev
The code to get the bias was incorrectly using the passed in map offset when reading it from memory. This doesn't work since the offset is the offset into the apk. Change to always check for a zero in this case. Bug: 28685297 Change-Id: I9ab2a89401429c4bcf4faa510b1b619be70318ab
-rw-r--r--src/elfxx.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/elfxx.c b/src/elfxx.c
index 7fda0b72..057a3baf 100644
--- a/src/elfxx.c
+++ b/src/elfxx.c
@@ -635,7 +635,11 @@ HIDDEN bool elf_w (get_load_base) (struct elf_image* ei, unw_word_t mapoff, unw_
Elf_W(Phdr) phdr;
GET_PHDR_FIELD(ei, offset, &phdr, p_type);
GET_PHDR_FIELD(ei, offset, &phdr, p_offset);
- if (phdr.p_type == PT_LOAD && phdr.p_offset == mapoff) {
+ // Always use zero as the map offset for in memory maps.
+ // The dlopen of a shared library from an APK will result in a
+ // non-zero map offset which would mean we would never find the
+ // correct program header using the passed in map offset.
+ if (phdr.p_type == PT_LOAD && phdr.p_offset == 0) {
GET_PHDR_FIELD(ei, offset, &phdr, p_vaddr);
*load_base = phdr.p_vaddr;
return true;