dlmopen and variables in the dynamic loader

Florian Weimer fweimer@redhat.com
Fri Aug 16 11:44:00 GMT 2019


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



More information about the Libc-alpha mailing list