changeset 57460:cf32454b65f0

8235637: jhsdb jmap from OpenJDK 11.0.5 doesn't work if prelink is enabled Summary: error handling for "lib_base_diff == 0" Reviewed-by: ysuenaga, cjplummer, kevinw Contributed-by: suenaga@oss.nttdata.com
author fmatte
date Tue, 24 Dec 2019 04:47:44 -0500
parents 77d6e5cf5320
children 2877992dadf9
files src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c	Mon Dec 23 17:18:32 2019 -0500
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c	Tue Dec 24 04:47:44 2019 -0500
@@ -520,6 +520,9 @@
 #define LINK_MAP_LD_OFFSET    offsetof(struct link_map, l_ld)
 #define LINK_MAP_NEXT_OFFSET  offsetof(struct link_map, l_next)
 
+#define INVALID_LOAD_ADDRESS -1L
+#define ZERO_LOAD_ADDRESS 0x0L
+
 // Calculate the load address of shared library
 // on prelink-enabled environment.
 //
@@ -536,7 +539,7 @@
   phbuf = read_program_header_table(lib_fd, elf_ehdr);
   if (phbuf == NULL) {
     print_debug("can't read program header of shared object\n");
-    return 0L;
+    return INVALID_LOAD_ADDRESS;
   }
 
   // Get the address of .dynamic section from shared library.
@@ -552,7 +555,7 @@
   if (ps_pdread(ph, (psaddr_t)link_map_addr + LINK_MAP_LD_OFFSET,
                &lib_ld, sizeof(uintptr_t)) != PS_OK) {
     print_debug("can't read address of dynamic section in shared object\n");
-    return 0L;
+    return INVALID_LOAD_ADDRESS;
   }
 
   // Return the load address which is calculated by the address of .dynamic
@@ -663,9 +666,9 @@
             // continue with other libraries...
          } else {
             if (read_elf_header(lib_fd, &elf_ehdr)) {
-               if (lib_base_diff == 0x0L) {
+               if (lib_base_diff == ZERO_LOAD_ADDRESS ) {
                  lib_base_diff = calc_prelinked_load_address(ph, lib_fd, &elf_ehdr, link_map_addr);
-                 if (lib_base_diff == 0x0L) {
+                 if (lib_base_diff == INVALID_LOAD_ADDRESS) {
                    close(lib_fd);
                    return false;
                  }