Hi Andrew,
I checked with GDB, readelf and libsaproc debug message.
I found that we should calculate .dynamic address from entry point in ELF.
I uploaded webrev. This patch works fine on JDK 9 and JDK 10.
http://cr.openjdk.java.net/~ysuenaga/JDK-8173941/webrev.00/
Thanks,
Yasumasa
On 2017/02/08 23:21, Yasumasa Suenaga wrote:
Hi Andrew,
I could reproduce it in my environment.
* libsaproc debug
```
libsaproc DEBUG: address of _DYNAMIC is 0x563bc6dd8d28
```
* Address of .dynamic in GDB
```
0x0000563bc6dd7d28 - 0x0000563bc6dd7f68 is .dynamic
```
It differs 1 page (0x1000).
In this case, according to GDB, `java` was loaded 0x563bc6dd7000.
According to readelf of `java`, offset of dynamic section is 0x1d28.
So I want to investigate why we found 1 memory page difference.
(Is it caused by ASLR? Do you have any idea?)
Thanks,
Yasumasa
On 2017/02/08 20:46, Andrew Haley wrote:
Okay, thanks.
The patch will have to be submitted to JDK 9 first and then back-
ported to earlier releases. Unfortunately it doesn't work on JDK 9.
I don't know why: I spent some time looking at it, but I couldn't
figure out what was wrong.
Is there any way you could have a look? This is using
hg.openjdk.java.net/jdk9/hs
on F25.
Thanks,
Andrew.
[aph@localhost hs-8173941]$ LIBSAPROC_DEBUG=1
./build/linux-x86_64-normal-server-fastdebug/images/jdk/bin/jhsdb jstack --core
core.63600 --exe build/linux-x86_64-normal-server-fastdebug/images/jdk/bin/java
Attaching to core core.63600 from executable
build/linux-x86_64-normal-server-fastdebug/images/jdk/bin/java, please wait...
libsaproc DEBUG: Note header with n_type = 3 and n_descsz = 136
libsaproc DEBUG: Note header with n_type = 1 and n_descsz = 336
libsaproc DEBUG: got integer regset for lwp 63600
libsaproc DEBUG: integer regset
...
libsaproc DEBUG: Note address of NT_FILE is 0x564be32e5000
libsaproc DEBUG: ELF interpreter /lib64/ld-linux-x86-64.so.2
libsaproc DEBUG: address of _DYNAMIC p_vaddr is 0x201d28
libsaproc DEBUG: address of _DYNAMIC is 0x564be32e6d28
libsaproc DEBUG: ---- sorted virtual address map ----
...
libsaproc DEBUG: base = 0x7fe62227c000 size = 4096
libsaproc DEBUG: base = 0x7ffeabb33000 size = 135168
libsaproc DEBUG: base = 0x7ffeabbc0000 size = 8192
libsaproc DEBUG: base = 0xffffffffff600000 size = 4096
libsaproc DEBUG: can't locate map_info at 0x564be32e7000
libsaproc DEBUG: core read failed for 16 byte(s) @ 0x564be32e7000 (8 more bytes)
libsaproc DEBUG: 1: can't read debug info from _DYNAMIC
Error attaching to core file: Can't attach to the core file
sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the core file
at
jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach0(Native
Method)
at
jdk.hotspot.agent/sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.attach(LinuxDebuggerLocal.java:286)
at
jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.attachDebugger(HotSpotAgent.java:679)
at
jdk.hotspot.agent/sun.jvm.hotspot.HotSpotAgent.setupDebuggerLinux(HotSpotAgent.java:617)