1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

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>
This commit is contained in:
Florian Weimer
2020-12-16 15:09:52 +01:00
parent 9459fe9da0
commit e7570f4131
9 changed files with 52 additions and 39 deletions

View File

@ -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;