[RFC][PATCH v7 07/20] elf/dl-open.c: Don't try libc linit in namespaces with no libc mapping
Vivek Das Mohapatra
vivek@collabora.com
Wed Dec 16 13:26:37 GMT 2020
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 | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 809845e5e9..a995e9086f 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -792,16 +792,21 @@ dl_open_worker (void *a)
namespace. */
if (!args->libc_already_loaded)
{
+ /* If this is a secondary (nsid != LM_ID_BASE) namespace then
+ it is POSSIBLE there's no libc_map at all - We use the one
+ shared with LM_ID_BASE instead (which MUST already be
+ initialised for us to even reach here). */
struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map;
#ifdef SHARED
- bool initial = libc_map->l_ns == LM_ID_BASE;
+ bool initial = libc_map && (libc_map->l_real->l_ns == LM_ID_BASE);
#else
/* In the static case, there is only one namespace, but it
contains a secondary libc (the primary libc is statically
linked). */
bool initial = false;
#endif
- _dl_call_libc_early_init (libc_map, initial);
+ if (libc_map != NULL)
+ _dl_call_libc_early_init (libc_map, initial);
}
#ifndef SHARED
--
2.20.1
More information about the Libc-alpha
mailing list