about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Versions2
-rw-r--r--elf/dl-open.c9
-rw-r--r--elf/rtld.c8
3 files changed, 18 insertions, 1 deletions
diff --git a/elf/Versions b/elf/Versions
index 1b02cd328c..ed5ba6f830 100644
--- a/elf/Versions
+++ b/elf/Versions
@@ -21,7 +21,7 @@ libc {
     _dl_profile; _dl_profile_map; _dl_profile_output; _dl_start_profile;
 
     # functions used in other libraries
-    _dl_mcount; _dl_mcount_wrapper; _dl_mcount_wrapper_check;
+    _dl_mcount; _dl_mcount_wrapper; _dl_mcount_wrapper_check; _dl_unload_cache;
   }
 }
 
diff --git a/elf/dl-open.c b/elf/dl-open.c
index b595f2df73..3670657379 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/mman.h>		/* Check whether MAP_COPY is defined.  */
 #include <bits/libc-lock.h>
 #include <elf/ldsodefs.h>
 
@@ -31,6 +32,9 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
 						     ElfW(Addr) *user_entry));
 weak_extern (_dl_sysdep_start)
 
+/* This function is used to unload the cache file if necessary.  */
+extern void _dl_unload_cache (void);
+
 extern int __libc_multiple_libcs;	/* Defined in init-first.c.  */
 
 extern int __libc_argc;
@@ -224,6 +228,11 @@ _dl_open (const char *file, int mode)
   args.map = NULL;
   errcode = _dl_catch_error (&errstring, dl_open_worker, &args);
 
+#ifndef MAP_COPY
+  /* We must munmap() the cache file.  */
+  _dl_unload_cache ();
+#endif
+
   /* Release the lock.  */
   __libc_lock_unlock (_dl_load_lock);
 
diff --git a/elf/rtld.c b/elf/rtld.c
index 3fd13179ba..13c4f2698e 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -40,6 +40,9 @@ extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
 						     ElfW(Addr) *user_entry));
 extern void _dl_sysdep_start_cleanup (void);
 
+/* This function is used to unload the cache file if necessary.  */
+extern void _dl_unload_cache (void);
+
 /* System-dependent function to read a file's whole contents
    in the most convenient manner available.  */
 extern void *_dl_sysdep_read_whole_file (const char *filename,
@@ -918,6 +921,11 @@ of this helper program; chances are you did not intend to run this program.\n\
     _dl_debug_state ();
   }
 
+#ifndef MAP_COPY
+  /* We must munmap() the cache file.  */
+  _dl_unload_cache ();
+#endif
+
   /* Now enable profiling if needed.  */
   if (_dl_profile_map != NULL)
     /* We must prepare the profiling.  */