summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2021-09-19 13:23:22 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-09-19 22:10:00 +0300
commite638c52c3dc6cf5dcf8ccc48155763622d29b8b5 (patch)
treef75bb7b7f4134dec58331141f8aef93a21ce5d65
parent24e50d19c84ce7089cc9e9f80be924979e29d147 (diff)
downloadbdwgc-e638c52c3dc6cf5dcf8ccc48155763622d29b8b5.tar.gz
Fix assertion violation in register_dynlib_callback on Android
(a cherry-pick of commit 3cbd5ec35 from 'release-7_4') * dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO] (GC_register_dynlib_callback): Round load_segs[j].end up to nearest page boundary in the assertion; add comment.
-rw-r--r--dyn_load.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/dyn_load.c b/dyn_load.c
index 707ff766..a994d05d 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -467,11 +467,15 @@ STATIC int GC_register_dynlib_callback(struct dl_phdr_info * info,
if (load_segs[j].start2 != 0) {
WARN("More than one GNU_RELRO segment per load seg\n",0);
} else {
- GC_ASSERT(end <= load_segs[j].end);
+ GC_ASSERT((word)end <=
+ (((word)load_segs[j].end + GC_page_size - 1) &
+ ~(GC_page_size - 1)));
/* Remove from the existing load segment */
load_segs[j].end2 = load_segs[j].end;
load_segs[j].end = start;
load_segs[j].start2 = end;
+ /* Note that start2 may be greater than end2 because of */
+ /* p->p_memsz value multiple of page size. */
}
break;
}