Question about dlopen load ordering
Caslyn Tonelli
caslyn.tonelli@gmail.com
Mon Jun 17 21:45:27 GMT 2024
Hello,
I’m hoping someone could help clarify the load ordering semantics of
glibc’s dlopen for a specific scenario:
multiple-foo-deps.so has the following DT_NEEDEDs in this order:
- libfoo-v1.so where foo() returns 2
- libfoo-v2.so where foo() returns 7
If I perform the following steps:
1. dlopen(“libfoo-v2.so”, RTLD_NOW | RTLD_LOCAL);
2. dlopen(“multiple-foo-deps.so”, RTLD_NOW | RTLD_LOCAL);
What would be the value of the resolved `foo()` from “multiple-foo-deps.so
”?
Based on POSIX documentation, I would expect the value to be 7 since “
libfoo-v2.so” was already loaded. However, my tests are showing that the
dependency order is prioritized and the foo symbol is resolved from “
libfoo-v1.so”. Is that right? Would someone be able to explain the
reasoning around this?
Let me know if I can clarify anything or provide a reproducer.
Thanks!
Caslyn
More information about the Libc-help
mailing list