This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
dlmopen and variables in the dynamic loader
- From: Florian Weimer <fweimer at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 16 Aug 2019 13:43:59 +0200
- Subject: dlmopen and variables in the dynamic loader
dlmopen carefully replicates the initial ld.so in all namespaces.
Unlike libc.so, ld.so is only loaded once. This can be used to share
state across all namespaces.
However, it turns out that there is an exception: If ld.so exports a
variable and the main program references it via a copy relocation,
secondary namespaces created via dlopen are bound to the original
definition in ld.so, not the copy in the main program. This means that
even without static dlopen, two copies of the same variable can exist in
the process.
For my case (__libc_single_threaded), I think I have a workaround. But
maybe someone else will run into this in a different context, hence this
note.
Thanks,
Florian