diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 273e477fbda5..b725fe93b8f6 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -325,7 +325,8 @@ map_object(int fd, const char *path, const struct stat *sb) } obj->stack_flags = stack_flags; obj->relro_page = obj->relocbase + trunc_page(relro_page); - obj->relro_size = round_page(relro_size); + obj->relro_size = trunc_page(relro_page + relro_size) - + trunc_page(relro_page); if (note_start < note_end) digest_notes(obj, note_start, note_end); if (note_map != NULL) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index f60872f12c52..eaad89339d07 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1557,7 +1557,8 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path) case PT_GNU_RELRO: obj->relro_page = obj->relocbase + trunc_page(ph->p_vaddr); - obj->relro_size = round_page(ph->p_memsz); + obj->relro_size = trunc_page(ph->p_vaddr + ph->p_memsz) - + trunc_page(ph->p_vaddr); break; case PT_NOTE: