summaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
Diffstat (limited to 'malloc')
-rw-r--r--malloc/set-freeres.c15
-rw-r--r--malloc/thread-freeres.c4
2 files changed, 17 insertions, 2 deletions
diff --git a/malloc/set-freeres.c b/malloc/set-freeres.c
index f4a0e7bda4..cda368479f 100644
--- a/malloc/set-freeres.c
+++ b/malloc/set-freeres.c
@@ -26,6 +26,10 @@ DEFINE_HOOK (__libc_subfreeres, (void));
symbol_set_define (__libc_freeres_ptrs);
+extern __attribute__ ((weak)) void __libdl_freeres (void);
+
+extern __attribute__ ((weak)) void __libpthread_freeres (void);
+
void __libc_freeres_fn_section
__libc_freeres (void)
{
@@ -39,8 +43,19 @@ __libc_freeres (void)
_IO_cleanup ();
+ /* We run the resource freeing after IO cleanup. */
RUN_HOOK (__libc_subfreeres, ());
+ /* Call the libdl list of cleanup functions
+ (weak-ref-and-check). */
+ if (&__libdl_freeres != NULL)
+ __libdl_freeres ();
+
+ /* Call the libpthread list of cleanup functions
+ (weak-ref-and-check). */
+ if (&__libpthread_freeres != NULL)
+ __libpthread_freeres ();
+
for (p = symbol_set_first_element (__libc_freeres_ptrs);
!symbol_set_end_p (__libc_freeres_ptrs, p); ++p)
free (*p);
diff --git a/malloc/thread-freeres.c b/malloc/thread-freeres.c
index 8902c845bc..a63b6c93f3 100644
--- a/malloc/thread-freeres.c
+++ b/malloc/thread-freeres.c
@@ -24,8 +24,8 @@
/* Thread shutdown function. Note that this function must be called
for threads during shutdown for correctness reasons. Unlike
- __libc_subfreeres, skipping calls to it is not a valid
- optimization. */
+ __libc_subfreeres, skipping calls to it is not a valid optimization.
+ This is called directly from pthread_create as the thread exits. */
void
__libc_thread_freeres (void)
{