Mon, 06 Jan 2020 21:22:25 +0900
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
agent/src/os/linux/ps_core.c | file | annotate | diff | comparison | revisions |
1.1 --- a/agent/src/os/linux/ps_core.c Tue Dec 17 17:25:50 2019 +0000 1.2 +++ b/agent/src/os/linux/ps_core.c Mon Jan 06 21:22:25 2020 +0900 1.3 @@ -868,6 +868,9 @@ 1.4 #define LINK_MAP_LD_OFFSET offsetof(struct link_map, l_ld) 1.5 #define LINK_MAP_NEXT_OFFSET offsetof(struct link_map, l_next) 1.6 1.7 +#define INVALID_LOAD_ADDRESS -1L 1.8 +#define ZERO_LOAD_ADDRESS 0x0L 1.9 + 1.10 // Calculate the load address of shared library 1.11 // on prelink-enabled environment. 1.12 // 1.13 @@ -884,7 +887,7 @@ 1.14 phbuf = read_program_header_table(lib_fd, elf_ehdr); 1.15 if (phbuf == NULL) { 1.16 print_debug("can't read program header of shared object\n"); 1.17 - return 0L; 1.18 + return INVALID_LOAD_ADDRESS; 1.19 } 1.20 1.21 // Get the address of .dynamic section from shared library. 1.22 @@ -900,7 +903,7 @@ 1.23 if (ps_pdread(ph, (psaddr_t)link_map_addr + LINK_MAP_LD_OFFSET, 1.24 &lib_ld, sizeof(uintptr_t)) != PS_OK) { 1.25 print_debug("can't read address of dynamic section in shared object\n"); 1.26 - return 0L; 1.27 + return INVALID_LOAD_ADDRESS; 1.28 } 1.29 1.30 // Return the load address which is calculated by the address of .dynamic 1.31 @@ -1011,9 +1014,9 @@ 1.32 // continue with other libraries... 1.33 } else { 1.34 if (read_elf_header(lib_fd, &elf_ehdr)) { 1.35 - if (lib_base_diff == 0x0L) { 1.36 + if (lib_base_diff == ZERO_LOAD_ADDRESS) { 1.37 lib_base_diff = calc_prelinked_load_address(ph, lib_fd, &elf_ehdr, link_map_addr); 1.38 - if (lib_base_diff == 0x0L) { 1.39 + if (lib_base_diff == INVALID_LOAD_ADDRESS) { 1.40 close(lib_fd); 1.41 return false; 1.42 }