diff options
-rw-r--r-- | sysdeps/generic/dl-cache.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c index 16f0da3c5a..7522b3e886 100644 --- a/sysdeps/generic/dl-cache.c +++ b/sysdeps/generic/dl-cache.c @@ -44,14 +44,16 @@ struct cache_file } libs[0]; }; +/* This is the starting address and the size of the mmap()ed file. */ +static struct cache_file *cache; +static size_t cachesize; + /* Look up NAME in ld.so.cache and return the file name stored there, or null if none is found. */ const char * _dl_load_cache_lookup (const char *name) { - static struct cache_file *cache; - static size_t cachesize; unsigned int i; const char *best; @@ -101,3 +103,19 @@ _dl_load_cache_lookup (const char *name) } return best; } + +#ifndef MAP_COPY +/* If the system does not support MAP_COPY we cannot leave the file open + all the time since this would create problems when the file is replaced. + Therefore we provide this function to close the file and open it again + once needed. */ +void +_dl_unload_cache (void) +{ + if (cache != NULL && cache != (struct cache_file *) -1) + { + __munmap (cache, cachesize); + cache = NULL; + } +} +#endif |