On Wed, 3 Feb 2021 22:17:16 GMT, Chris Plummer <[email protected]> wrote:
>> We could see NPE on `LinuxCDebugger::loadObjectContainingPC` which is used >> mainly by the clhsdb `findpc` command. (See >> [JDK-8248876](https://bugs.openjdk.java.net/browse/JDK-8248876) for more >> details) >> >> It is caused by PIE executable handling. >> >> Currently we use virtual address of top of PT_LOAD in executable as base >> address - it is valid for ET_EXEC binary. >> However, in case of ET_DYN binary (PIE binary), we should handle it like a >> shared library. >> In GDB, base address of executable would be calculated by dynamic section. >> SA should also do so. > > Marked as reviewed by cjplummer (Reviewer). Hi! I found the "svr4_exec_displacement() in GDB" more confusing than informative, maybe this is the same technique GDB uses... But I followed our dynamic_addr setting and agree with the new changes. An alternative comment could be this, which would also removes the "substract" typo (which was not yours!): ps_core.c 509 } else { // ET_DYN // dynamic_addr was initially set to entry point (AT_ENTRY). // Now subtract the entry point offset to get load address: result = ph->core->dynamic_addr - exec_ehdr->e_entry; // Find actual dynamic_addr: ph->core->dynamic_addr += exec_php->p_vaddr - exec_ehdr->e_entry; } ------------- PR: https://git.openjdk.java.net/jdk/pull/2366
