The ABI status of ELF hash tables
The ABI status of ELF hash tables
Posted Aug 21, 2022 11:14 UTC (Sun) by jengelh (guest, #33263)In reply to: The ABI status of ELF hash tables by scientes
Parent article: The ABI status of ELF hash tables
That sounds just like RTLD_LOCAL on ELF systems. Moreover, I don't see ld.so using RTLD_GLOBAL during the initial program start, that seems to be a dlopen-exclusive. So shouldn't symbols be appropirately namespaced? (But indeed I remember symbols sharing the global scope, dunno what's going on.)
Posted Aug 22, 2022 17:00 UTC (Mon)
by mathstuf (subscriber, #69389)
[Link]
pluginA.so -> liblang.so
Loading pluginA with RTLD_LOCAL makes liblang.so enter the same state. When pluginB is loaded, it fails because it is not "allowed" to access liblang.so because it is "local" to pluginA. It's probably more useful when you know plugins are standalone or you're doing some restricted delay-load mechanism.
Posted Aug 23, 2022 2:55 UTC (Tue)
by bartoc (guest, #124262)
[Link] (1 responses)
You can actually have stuff like multiple different C runtimes in the same process (although it's super likely to result in sadness and chaos as soon as one touches the other). Still, if you are very careful it is possible. They do need to be named differently though.
Not to mention if you load C++ libraries with RTLD_LOCAL they usually can't be unloaded anyway, _AND_ some (but not all) of their symbols will actually be used to resolve references in future libraries. RTLD_LOCAL can also be promoted to RTLD_GLOBAL if the library is a dependency of an RTLD_GLOBAL library.
dlmopen provides something much more similar to windows DLLs, but you can only have 16 namespaces and according to the manual (typos from there):
So it seems like it's a little useless. Someone should fix this stuff, and perhaps allow some kind of namespacing for stuff used via the linker, without dlsym. I guess if you really want that you can just use wine's loader.
Posted Aug 23, 2022 11:47 UTC (Tue)
by mathstuf (subscriber, #69389)
[Link]
Pretty much anything with global statics is nigh unloadable already. macOS just no-ops unloading anything that mentions `thread_local` as well. I don't see much value in being able to unload libraries. Windows is a bit different because there are APIs to query libraries without actually loading them (but is not that useful to anything caring about cross-platform support).
The ABI status of ELF hash tables
pluginB.so -> liblang.so
The ABI status of ELF hash tables
> As at glibc 2.24, specifying the RTLD_GLOBAL flag when calling
dlmopen() generates an error. Furthermore, specifying
RTLD_GLOBAL when calling dlopen() results in a program crash
(SIGSEGV) if the call is made from any object loaded in a
namespace other than the initial namespace.
The ABI status of ELF hash tables