aboutsummaryrefslogtreecommitdiff
path: root/csu
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-12-16 15:09:52 +0100
committerFlorian Weimer <fweimer@redhat.com>2020-12-16 15:13:40 +0100
commite7570f4131a6af9405af7b4fd1c31de807e7cf68 (patch)
tree0f11050a7a1b768fb0d683dc60412bc2a101c3a5 /csu
parent9459fe9da0f981f77ba931790f82e43ac552b73c (diff)
downloadglibc-e7570f4131a6af9405af7b4fd1c31de807e7cf68.zip
glibc-e7570f4131a6af9405af7b4fd1c31de807e7cf68.tar.gz
glibc-e7570f4131a6af9405af7b4fd1c31de807e7cf68.tar.bz2
Replace __libc_multiple_libcs with __libc_initial flag
Change sbrk to fail for !__libc_initial (in the generic implementation). As a result, sbrk is (relatively) safe to use for the __libc_initial case (from the main libc). It is therefore no longer necessary to avoid using it in that case (or updating the brk cache), and the __libc_initial flag does not need to be updated as part of dlmopen or static dlopen. As before, direct brk system calls on Linux may lead to memory corruption. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'csu')
-rw-r--r--csu/init-first.c10
-rw-r--r--csu/libc-start.c13
2 files changed, 8 insertions, 15 deletions
diff --git a/csu/init-first.c b/csu/init-first.c
index 47aaacd..2115215 100644
--- a/csu/init-first.c
+++ b/csu/init-first.c
@@ -28,10 +28,6 @@
#include <ldsodefs.h>
-/* Set nonzero if we have to be prepared for more than one libc being
- used in the process. Safe assumption if initializer never runs. */
-int __libc_multiple_libcs attribute_hidden = 1;
-
/* Remember the command line argument and enviroment contents for
later calls of initializers for dynamic libraries. */
int __libc_argc attribute_hidden;
@@ -50,16 +46,16 @@ _init_first (int argc, char **argv, char **envp)
{
#endif
- __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
-
/* Make sure we don't initialize twice. */
- if (!__libc_multiple_libcs)
+#ifdef SHARED
+ if (__libc_initial)
{
/* Set the FPU control word to the proper default value if the
kernel would use a different value. */
if (__fpu_control != GLRO(dl_fpu_control))
__setfpucw (__fpu_control);
}
+#endif
/* Save the command-line arguments. */
__libc_argc = argc;
diff --git a/csu/libc-start.c b/csu/libc-start.c
index 2d4d2ed..d330812 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -141,8 +141,6 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
/* Result of the 'main' function. */
int result;
- __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
-
#ifndef SHARED
_dl_relocate_static_pie ();
@@ -213,12 +211,11 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
# endif
# ifdef DL_SYSDEP_OSCHECK
- if (!__libc_multiple_libcs)
- {
- /* This needs to run to initiliaze _dl_osversion before TLS
- setup might check it. */
- DL_SYSDEP_OSCHECK (__libc_fatal);
- }
+ {
+ /* This needs to run to initiliaze _dl_osversion before TLS
+ setup might check it. */
+ DL_SYSDEP_OSCHECK (__libc_fatal);
+ }
# endif
/* Initialize libpthread if linked in. */