Hi,
apologies for late reply.
The reason we use syslookup on Linux too is that we wanted to make the
set of symbols findable via default lookup _stable_.
While RTLD_DEFAULT works (and we used that for quite a while), what it
really does is that it exposes _all_ the symbols loaded in the current
process, including those defined in any libraries the JVM might load (or
exported by the JVM itself!).
While a good approximation, this is ultimately not what the API wanted
to do.
Maurizio
On 07/04/2026 06:26, suenaga wrote:
Hi all,
I found libsyslookup.so in lib directory in JDK, and it seems to be
used in `SystemLookup` in FFM to find symbols from the system. But I
wonder why SystemLookup depends on libsyslookup on Linux. I think it
is not needed on Linux with some changes.
I understand syslookup.dll is needed for Windows because some
functions might not be lookup'ed. OTOH on Linux, `dlsym` can lookup
symbols from library dependencies. In `SystemLookup`, handle of
libsyslookup would be passed to `dlsym` eventually, but I think it is
better to pass `RTLD_DEFAULT` in this case. I know it works when the
handle of libsyslookup is passed, but `RTLD_DEFAULT` is better because
Javadoc of `Linker::defaultLookup` says it returns a set of commonly
used libraries. I guess the reson of use libsyslookup is to use
`NativeLibraryImpl`.
I think we can fix not to use libsyslookup like [1]. It works on Linux
(including static image of course). If it does not have a problem, I
want to create JBS issue and PR for this. Do you have any comments?
In addition, I guess we can apply this change to all of POSIX
platforms because `dlsym` is defined in POSIX, but I'm not sure we can
do (especially AIX - it has own syslookup.c in JDK source tree).
Thanks,
Yasumasa
[1]
https://github.com/YaSuenag/jdk/commit/b125cc164d60ac14316549e59d18544d75f6fcb2