Suppose I have an executable that dlopens libfirst.so with RTLD_LOCAL which then dlopens libsecond.so with RTLD_GLOBAL. Should the symbols from libsecond.so now be directly available (i.e., without dlsym) in (1) only libfirst.so or (2) in both libfirst.so and the executable?
From the manpage on dlopen
RTLD_GLOBAL: The symbols defined by this shared object will be made available for symbol resolution of subsequently loaded shared objects.
This sounds like the symbols from libsecond.so are not made available to either the executable or libfirst.so (except via dlsym). Is this correct?
I don't think you understand what "directly available" means in this context.
Suppose
libsecond.sodefinessecond(). That symbol is not available in eitherlibfirst.soor the maina.out(obviously -- they have been already loaded beforelibsecond.sowas brought in).But if you now load (via
dlopen())libthird.so, and if that library hassecond()as an unresolved symbol (in other words,libthird.sohas a direct dependency onsecond()), the load oflibthird.sowould succeed iflibsecond.sowas loaded withRTLD_GLOBAL, but would fail (with unresolvedsecond()) iflibsecond.sowas loaded withRTLD_LOCAL.