From e7570f4131a6af9405af7b4fd1c31de807e7cf68 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 16 Dec 2020 15:09:52 +0100 Subject: 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 --- sysdeps/mach/hurd/dl-sysdep.c | 2 -- sysdeps/mach/hurd/i386/init-first.c | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sysdeps/mach/hurd') diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 370495710e..a5169d85e7 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -57,8 +57,6 @@ extern char **_environ; int __libc_enable_secure = 0; rtld_hidden_data_def (__libc_enable_secure) -int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion - of init-first. */ /* This variable contains the lowest stack address ever used. */ void *__libc_stack_end = NULL; rtld_hidden_data_def(__libc_stack_end) diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index 1827479f86..cbbc12204a 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -30,6 +30,7 @@ #include #include #include +#include extern void __mach_init (void); extern void __init_misc (int, char **, char **); @@ -40,7 +41,6 @@ unsigned long int __hurd_threadvar_stack_mask; #ifndef SHARED int __libc_enable_secure; #endif -int __libc_multiple_libcs attribute_hidden = 1; extern int __libc_argc attribute_hidden; extern char **__libc_argv attribute_hidden; @@ -56,13 +56,12 @@ DEFINE_HOOK (_hurd_preinit_hook, (void)); static void posixland_init (int argc, char **argv, char **envp) { - __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up; - /* Now we have relocations etc. we can start signals etc. */ _hurd_libc_proc_init (argv); +#ifdef SHARED /* Make sure we don't initialize twice. */ - if (!__libc_multiple_libcs) + if (__libc_initial) { /* Set the FPU control word to the proper default value. */ __setfpucw (__fpu_control); @@ -72,6 +71,9 @@ posixland_init (int argc, char **argv, char **envp) /* Initialize data structures so the additional libc can do RPCs. */ __mach_init (); } +#else /* !SHARED */ + __setfpucw (__fpu_control); +#endif /* Save the command-line arguments. */ __libc_argc = argc; -- cgit 1.4.1