* elf/dl-fini.c (_dl_fini): Call destructors of audit DSOs after
	those of all the regular objects.
This commit is contained in:
Ulrich Drepper 2005-01-09 10:42:33 +00:00
parent 29f976542b
commit e145f1cc75
2 changed files with 22 additions and 3 deletions

View File

@ -1,5 +1,8 @@
2005-01-09 Ulrich Drepper <drepper@redhat.com>
* elf/dl-fini.c (_dl_fini): Call destructors of audit DSOs after
those of all the regular objects.
* elf/dl-debug.c (_dl_debug_initialize): Take extra parameter and
use it to select the r_debug structure for that namespace.
* elf/dl-close.c (_dl_close): Adjust call to _dl_debug_initialize.

View File

@ -1,5 +1,5 @@
/* Call the termination functions of loaded shared objects.
Copyright (C) 1995,96,1998-2002,2004 Free Software Foundation, Inc.
Copyright (C) 1995,96,1998-2002,2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -48,6 +48,10 @@ _dl_fini (void)
/* We run the destructors of the main namespaces last. As for the
other namespaces, we pick run the destructors in them in reverse
order of the namespace ID. */
#ifdef SHARED
int do_audit = 0;
again:
#endif
for (Lmid_t cnt = DL_NNS - 1; cnt >= 0; --cnt)
{
/* Protect against concurrent loads and unloads. */
@ -57,7 +61,11 @@ _dl_fini (void)
unsigned int nloaded = GL(dl_ns)[cnt]._ns_nloaded;
/* No need to do anything for empty namespaces or those used for
auditing DSOs. */
if (nloaded == 0 || GL(dl_ns)[cnt]._ns_loaded->l_auditing)
if (nloaded == 0
#ifdef SHARED
|| GL(dl_ns)[cnt]._ns_loaded->l_auditing != do_audit
#endif
)
goto out;
/* XXX Could it be (in static binaries) that there is no object
@ -213,7 +221,7 @@ _dl_fini (void)
#ifdef SHARED
/* Auditing checkpoint: another object closed. */
if (__builtin_expect (GLRO(dl_naudit) > 0, 0))
if (!do_audit && __builtin_expect (GLRO(dl_naudit) > 0, 0))
{
struct audit_ifaces *afct = GLRO(dl_audit);
for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
@ -233,6 +241,14 @@ _dl_fini (void)
}
}
#ifdef SHARED
if (! do_audit && GLRO(dl_naudit) > 0)
{
do_audit = 1;
goto again;
}
#endif
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS, 0))
_dl_debug_printf ("\nruntime linker statistics:\n"
" final number of relocations: %lu\n"