On Mon, 19 Oct 2026 19:50:20 GMT, Kevin Walls <[email protected]> wrote:

>> musl C is `/lib/ld-musl-x86_64.so.1`. (You can see it on Alpine container)
>
> Hi, I removed the specific "libc" lookup, thanks...
> This was about making libc address range protected from accidental overwrite 
> by the core mappings, so found the location differently.
> init_pd() in revival_linux.cpp looks up the printf location, its library, and 
> sets a range from that.  I have not done an Alpine build and test, we don't 
> do that regularly, so there might be more to discover on that platform.

I think it could get incorrect address if `LD_PRELOAD` is set to override 
`printf`.

Originally, I guess you want to ensure the address which should be allocated do 
not conflict with existed memory maps. Then we can use `MAP_FIXED_NOREPLACE` 
flag in `mmap()`. If we need to ensure to work on Linux 4.16 or earlier, we can 
check return address from `mmap()` is different from what we requested.

If we identify libc address, we need to check `DT_NEEDED` in `.dynamic` section 
in ELF. libc would be started with `libc.` in glibc and musl C at least. But 
ELF parser would be complicated if we can't use external library like libelf.
SA (libsaproc.so and `sun.jvm.hotspot.debugger.posix.elf`) has partially ELF 
parser, but they do not seem to extract `DT_NEEDED` from the binary.

glibc:

 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]


musl C:

 0x0000000000000001 (NEEDED)             Shared library: [libc.musl-x86_64.so.1]

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31011#discussion_r4321615543

Reply via email to