Re: Stuff dragged in by crt1 (was Re: Announce: initrd-tftp 0.1)

From: Zack Weinberg (zack@wolery.cumb.org)
Date: Mon Jan 10 2000 - 19:00:28 EST


On Mon, Jan 10, 2000 at 03:41:31PM -0800, Ulrich Drepper wrote:
> Zack Weinberg <zack@wolery.cumb.org> writes:
>
> > I created an internal entry point that doesn't use malloc, which is safe
> > because we're executing before any user code does so we know we have room
> > in the static atexit table.
>
> That's not true. Global constructors unfortunately exist and it is
> allowed (and through C++ code will happen very frequently) to call
> atexit etc.
>
> There is a problem with all these constructors and until we have
> priorities in constructors (or at least the preinit support) there
> will always be problems popping up.

I know about global constructors, but if you look closely at libc-start.c
you will see that what I said is still true.

  /* Register the destructor of the dynamic linker if there is any. */
  if (rtld_fini != NULL)
    __internal_atexit (rtld_fini);

  /* Call the initializer of the libc. */
  __libc_init_first (argc, argv, __environ);

  /* Register the destructor of the program, if any. */
  if (fini)
    __internal_atexit (fini);

  /* Call the initializer of the program, if any. */
  if (init)
    (*init) ();

The constructors you are worried about are all executed by (*init)().
We control the code executed by __libc_init_first, and in the current source
base none of it calls atexit. Therefore, we can be absolutely certain that
the above __internal_atexit calls are safe.

zw

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:17 EST