RFR: 8248876: LoadObject with bad base address created for exec file on linux [v2]

Yasumasa Suenaga ysuenaga at openjdk.java.net
Tue Feb 9 07:38:40 UTC 2021


On Mon, 8 Feb 2021 18:49:51 GMT, Kevin Walls <kevinw at openjdk.org> wrote:

> Oops, I didn't mean to suggest the comment should go entirely. It's actually very useful to say something here, as the way we use the dynamic field, setting it then fixing it up.
> Is it possible to re-add the comment in a new change?

I thought your thumbs-up emoji means to agree to remove all comments.

As you know, I've integrated this PR, so we need to file as a new ticket.
I will do it and send a PR with following patch if you are ok.

diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
index dff4cb3eeca..9f7c4050ef2 100644
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
@@ -507,7 +507,11 @@ static uintptr_t read_exec_segments(struct ps_prochandle* ph, ELF_EHDR* exec_ehd
         result = exec_php->p_vaddr;
         ph->core->dynamic_addr = exec_php->p_vaddr;
       } else { // ET_DYN
+        // Base address of executable is based on entry point (AT_ENTRY).
         result = ph->core->dynamic_addr - exec_ehdr->e_entry;
+
+        // dynamic_addr has entry point of executable.
+        // Thus we should subtract it.
         ph->core->dynamic_addr += exec_php->p_vaddr - exec_ehdr->e_entry;
       }
       print_debug("address of _DYNAMIC is 0x%lx\n", ph->core->dynamic_addr);

-------------

PR: https://git.openjdk.java.net/jdk/pull/2366


More information about the serviceability-dev mailing list