about summary refs log tree commit diff
path: root/elf/dl-open.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-04-29 15:44:03 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-04-29 15:44:03 +0200
commit03e187a41d91069543cfcf33469a05912e555447 (patch)
treea2f3afcc3e41af612e40fc9cab1ba9b3a811ce38 /elf/dl-open.c
parent2ad5d0845d80589d0adf86593bd36a7c71a521f8 (diff)
downloadglibc-03e187a41d91069543cfcf33469a05912e555447.tar.gz
glibc-03e187a41d91069543cfcf33469a05912e555447.tar.xz
glibc-03e187a41d91069543cfcf33469a05912e555447.zip
elf: Add initial flag argument to __libc_early_init
The rseq initialization should happen only for the libc in the base
namespace (in the dynamic case) or the statically linked libc.  The
__libc_multiple_libcs flag does not quite cover this case at present,
so this commit introduces a flag argument to __libc_early_init,
indicating whether the libc being libc is the primary one (of the main
program).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r--elf/dl-open.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index ac7ab495e4..ddcb8b53fc 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -748,9 +748,22 @@ dl_open_worker (void *a)
     LIBC_PROBE (reloc_complete, 3, args->nsid, r, new);
 
   /* If libc.so was not there before, attempt to call its early
-     initialization routine.  */
+     initialization routine.  Indicate to the initialization routine
+     whether the libc being initialized is the one in the base
+     namespace.  */
   if (!args->libc_already_loaded)
-    _dl_call_libc_early_init (GL(dl_ns)[args->nsid].libc_map);
+    {
+      struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map;
+#ifdef SHARED
+      bool initial = libc_map->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);
+    }
 
 #ifndef SHARED
   DL_STATIC_INIT (new);