about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile2
-rw-r--r--elf/dl-iteratephdr.c8
-rw-r--r--elf/link.h2
3 files changed, 11 insertions, 1 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 7554962fb4..734b7854e8 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -84,6 +84,8 @@ distribute	:= rtld-Rules \
 
 CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-dl-iterate-phdr.c = $(uses-callbacks)
+CFLAGS-dl-iterate-phdr-static.c = $(uses-callbacks)
 
 include ../Makeconfig
 
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index dccaf0aff8..d4feb690c3 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -23,6 +23,12 @@
 #include <stddef.h>
 #include <bits/libc-lock.h>
 
+static void
+cancel_handler (void *arg __attribute__((unused)))
+{
+  __rtld_lock_unlock_recursive (GL(dl_load_lock));
+}
+
 int
 __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
 				    size_t size, void *data), void *data)
@@ -33,6 +39,7 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
 
   /* Make sure we are alone.  */
   __rtld_lock_lock_recursive (GL(dl_load_lock));
+  __libc_cleanup_push (cancel_handler, 0);
 
   for (l = GL(dl_loaded); l != NULL; l = l->l_next)
     {
@@ -46,6 +53,7 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
     }
 
   /* Release the lock.  */
+  __libc_cleanup_pop (0);
   __rtld_lock_unlock_recursive (GL(dl_load_lock));
 
   return ret;
diff --git a/elf/link.h b/elf/link.h
index f8e7f629d0..7e2a8f6fee 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -106,7 +106,7 @@ __BEGIN_DECLS
 
 extern int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
 					     size_t size, void *data),
-			    void *data) __THROW;
+			    void *data);
 
 __END_DECLS