Forward-ported from cl/51433387 (from cl/38694-p2, cl/38725-p2, and
cl/38741-p2).
(ppluzhnikov, google-local)
+
+elf/dl-cache.c
+elf/dl-load.c
+include/dlfcn.h
+sysdeps/generic/ldsodefs.h
+ For b/3133396, ignore system ld.so.cache when looking for
+ nss and iconv modules.
+ Forward-ported from cl/51433604 (from cl/44863-p2).
+ (ppluzhnikov, google-local)
+
file name stored there, or null if none is found. */
const char *
internal_function
-_dl_load_cache_lookup (const char *name)
+_dl_load_cache_lookup (const char *name, int mode)
{
struct cache_info *info;
/* Caches have not been initialized yet. */
cache_info = _dl_alloc_cache_info (GLRO(google_ld_so_cache_list));
+ if (mode & __RTLD_GOOGLE_IGNORE_HOST_LD_SO_CACHE)
+ {
+ /* We are loading a component of glibc itself (e.g. nss or iconv).
+ Such components must not be loaded from host, only from this
+ glibc compilation (which must always be the first component of
+ the cache list). See b/3133396 */
+
+ return _dl_load_cache_lookup_2 (name, cache_info);
+ }
+
for (info = cache_info; info->ld_so_cache != NULL; ++info)
{
const char *result;
{
/* Check the list of libraries in the file /etc/ld.so.cache,
for compatibility with Linux's ldconfig program. */
- const char *cached = _dl_load_cache_lookup (name);
+ const char *cached = _dl_load_cache_lookup (name, mode);
if (cached != NULL)
{
#define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
#define __RTLD_NOIFUNC 0x02000000 /* Suppress calling ifunc functions. */
+/* Google-local; use only $prefix/etc/ld.so.cache.
+ See b/3133396 */
+#define __RTLD_GOOGLE_IGNORE_HOST_LD_SO_CACHE 0x01000000
+
#define __LM_ID_CALLER -2
#ifdef SHARED
/* Now define the internal interfaces. */
#define __libc_dlopen(name) \
- __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN)
+ __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN | \
+ __RTLD_GOOGLE_IGNORE_HOST_LD_SO_CACHE)
extern void *__libc_dlopen_mode (const char *__name, int __mode);
extern void *__libc_dlsym (void *__map, const char *__name);
extern int __libc_dlclose (void *__map);
/* Look up NAME in ld.so.cache and return the file name stored there,
or null if none is found. */
-extern const char *_dl_load_cache_lookup (const char *name)
+extern const char *_dl_load_cache_lookup (const char *name, int mode)
internal_function;
/* If the system does not support MAP_COPY we cannot leave the file open