summaryrefslogtreecommitdiff
path: root/math/s_clogf.c
diff options
context:
space:
mode:
authorVivek Das Mohapatra <vivek@collabora.com>2021-08-03 10:22:22 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-09-27 13:57:48 -0300
commit010fc01f004241b6afcae92f2d20fe47e6869f72 (patch)
tree730e0ee3e7c1b0d543f9cf54f78bda99acb8825c /math/s_clogf.c
parente53e26dc0c90090406e70fc86c5603d31471c17d (diff)
downloadglibc-010fc01f004241b6afcae92f2d20fe47e6869f72.tar.gz
elf: Implement dlmopen RTLD_SHARED flag (BZ #22745)
This flag will instruct dlmopen to create a shared object present in the main namespace and accessible from the selected namespace when supplied in the MODE argument. include/link.h: Update the link_map struct to allow proxies We already have an l_real pointer, used for a similar purpose by the linker for copies of ld.so in secondary namespaces. Update its documentation and add a bitfield to indicate when link_map entry is a proxy. elf/dl-object.c: Implement a helper function to proxy link_map entries Provides the minimal functionality needed to take an existing link_map entry and create a proxy for it in the specified namespace. elf/dl-load.c, elf/dl-open.c: Implement RTLD_SHARED dlmopen proxying This uses the new infrastructure to implement RTLD_SHARED object proxying via dlmopen: Instead of opening the specified object in the requested namespace we open it in the main namespace (if it is not already present there) and proxy it to the destination. The following rules apply: If a proxy of the object is already present in the requested namespace, we simply return it (with an incremented direct-open count). If the object is already present in the requested namespace, a dl error is signalled, since we cannot satisfy the user's request. Proxies are never created in the main namespace: RTLD_SHARED has no effect when the requested namespace is LM_ID_BASE. elf/dl-fini.c: Handle proxy link_maps in the shutdown path (bug 22745) When cleaning up before exit we should not call destructors or otherwise free [most of] the contents of proxied link_map entries since they share [most of] their contents with the LM_ID_BASE objects to which they point. elf/dl-init.c: Skip proxy link_map entries in dl init path Proxies should not trigger calls to DT_INIT constructors since they're just shims that point to the real, already loaded and initialised, objects. elf/dl-open.c: Skip libc init if namespace has no libc map Secondary namespaces which share their libc mapping with the main namespace cannot (and should not) have _dl_call_libc_early_init called for them by dl_open_worker. elf/dl-open.c: When creating a proxy check NS 0 libc map The libc_already_loaded check normally considers the libc_map entry in GL(dl_ns)[args->nsid].libc_map. This is not correct for proxies, which use the libc_map from the default namespace (as proxies are dummy entries that point to the base namespace via their l_real members). elf/dl-load.c, dl-open.c: Compare DSOs by file ID & check DF_GNU_1_UNIQUE If _dl_map_object_from_fd finds that a DSO it was asked to load into a non-base namespace is already loaded (into the main namespace) and is flagged DF_GNU_1_UNIQUE then it should return that DSO's link map entry. In such cases _dl_open_worker must notice that this has happened and continue down the link map proxy generation path instead of normal link map entry preparation. elf/dl-load.c: error if RTLD_SHARED = DF_GNU_1_UNIQUE semantics violated elf/dl-open.c: Use search helper to find preloaded DT_GNU_UNIQUE DSOs If a DSO already exists (with the same name) in the base namespace and it is flagged DT_GNU_UNIQUE then we should behave as if a proxy had been requested. elf/dl-load.c: When loading DSOs in other namespaces check DT_GNU_UNIQUE If a DSO has not already been loaded and the target is not the main namespace then we must check to see if it's been DT_GNU_UNIQUE tagged and load it into the main namespace instead. dl_open_worker has alread been modified to notice the discrepancy between the request and the result in such cases, and will set up a proxy in the target namespace. elf/dl-load.c: Suppress audit calls when a (new) namespace is empty When preparing an RTLD_SHARED proxy in a new namespace it is possible for the target namespace to be empty: This can happen for RTLD_SHARED + LM_ID_NEWLM. The audit infrastructure should not be invoked at this point (as there's nothing there to audit yet). bits/dlfcn.h, elf/dl-load.c, elf/dl-open.c, elf/rtld.c, sysdeps/mips/bits/dlfcn.h: Suppress inter-namespace DSO sharing for audit libraries Audit libraries should not participate in DSO sharing: In particular libraries tagged with DF_GNU_1_UNIQUE should not be shared between the audit namespace and any others - they should get their own copy. This is signalled to the loader code by passing the RTLD_ISOLATE flag from the relevant entry point in the dl modes argument. elf/dl-sym.c: dlsym, dlvsym must be able to resolve symbols via proxies tst-tls-ie-dlmopen checks to see that new namespaces consume TLS memory as expected: This does not happen when new namespaces share the same libc instance (since TLS is allocated only when a new libc instance insitialises its threading infrastructure). Adding RTLD_ISOLATE to the dlmopen flags in the test restores the old behaviour which allows the test to check what it actually needs to. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'math/s_clogf.c')
0 files changed, 0 insertions, 0 deletions