From e455cb087f90a4f4cd84885ceb6f878d08120366 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Mon, 17 May 2021 21:56:07 +0000 Subject: [PATCH] Use p_memsz instead of p_filesz to correctly compute segment size. --- src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c index fcddae9c4ca2a..5fca59841cf75 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c @@ -187,8 +187,9 @@ static bool fill_addr_info(lib_info* lib) { lib->exec_end = (uintptr_t)-1L; for (ph = phbuf, cnt = 0; cnt < ehdr.e_phnum; cnt++, ph++) { if (ph->p_type == PT_LOAD) { - uintptr_t aligned_start = align_down(lib->base + ph->p_vaddr, ph->p_align); - uintptr_t aligned_end = align_up(aligned_start + ph->p_filesz, ph->p_align); + uintptr_t unaligned_start = lib->base + ph->p_vaddr; + uintptr_t aligned_start = align_down(unaligned_start, ph->p_align); + uintptr_t aligned_end = align_up(unaligned_start + ph->p_memsz, ph->p_align); if ((lib->end == (uintptr_t)-1L) || (lib->end < aligned_end)) { lib->end = aligned_end; } @@ -540,4 +541,3 @@ ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset) { print_debug("ps_lgetfpregs not implemented\n"); return PS_OK; } -