]> sourceware.org Git - glibc.git/commitdiff
New ld.so argument --inhibit-ldcache to disable ld.so.cache lookup
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Wed, 4 Apr 2012 14:39:09 +0000 (20:09 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Tue, 10 Apr 2012 18:43:52 +0000 (00:13 +0530)
It may sometimes be desirable to make the dynamic linker only pick up
libraries from the library path and rpath and not look at the
ld.so.cache that ldconfig generates. An example of such a use case is
the glibc testsuite where the dynamic linker must not be influenced by
any external paths or caches.

This change adds a new option --inhibit-ldcache that when used, tells
the dynamic linker to not use ld.so.cache even if it is available.

ChangeLog
elf/Makefile
elf/dl-load.c
elf/dl-support.c
elf/rtld.c
sysdeps/generic/ldsodefs.h

index cede7b8ee3bf62dcad6485df950cf5515de1523c..80b38fc2ac332375e2a21abe4ac96fe5725595b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-04-10  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+       * elf/dl-support.c (_dl_inhibit_cache): New variable.
+       * elf/rtld.c (_rtld_global_ro): New member _dl_inhibit_cache.
+       (dl_main): Handle --inhibit-cache.
+       * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): New member
+       _dl_inhibit_cache.
+       * elf/dl-load.c (_dl_map_object): Use it.
+       * elf/Makefile: Define SYSCONFDIR when building rtld.c.
+
 2012-04-09  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #13872]
index 59a3936a1b5bc912d18cf00658802f85cb9e972a..a77e792cb478952c82ad353f793628315d143c1d 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 1995-2011, 2012 Free Software Foundation, Inc.
+# Copyright (C) 1995-2012 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -419,6 +419,7 @@ CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
                    -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
 CFLAGS-cache.c = $(SYSCONF-FLAGS)
+CFLAGS-rtld.c = $(SYSCONF-FLAGS)
 
 CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
 
index 41d48ee13831cf4585a04c2846b577825210da69..fe83f87eb9e72b2373609a1dc54f5dab95381373 100644 (file)
@@ -1,5 +1,5 @@
 /* Map in a shared object's segments from the file.
-   Copyright (C) 1995-2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -2194,7 +2194,8 @@ _dl_map_object (struct link_map *loader, const char *name,
 
       if (fd == -1
          && (__builtin_expect (! (mode & __RTLD_SECURE), 1)
-             || ! INTUSE(__libc_enable_secure)))
+             || ! INTUSE(__libc_enable_secure))
+         && __builtin_expect (GLRO(dl_inhibit_cache) == 0, 1))
        {
          /* Check the list of libraries in the file /etc/ld.so.cache,
             for compatibility with Linux's ldconfig program.  */
index 565f342e6bc2e91277eb921c98c69c18b48ad892..a0f212207194e5afb7506ea63d58912af025afa5 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for dynamic linking code in static libc.
-   Copyright (C) 1996-2008,2009,2010,2011 Free Software Foundation, Inc.
+   Copyright (C) 1996-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -107,6 +107,8 @@ void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls;
 
 size_t _dl_pagesize = EXEC_PAGESIZE;
 
+int _dl_inhibit_cache;
+
 unsigned int _dl_osversion;
 
 /* All known directories in sorted order.  */
index 0362b14968b9259b844af59efde4e6483fe7484d..88a340d1ee544a3ede49c03d1654f3d28b706434 100644 (file)
@@ -161,6 +161,7 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
     ._dl_fpu_control = _FPU_DEFAULT,
     ._dl_pointer_guard = 1,
     ._dl_pagesize = EXEC_PAGESIZE,
+    ._dl_inhibit_cache = 0,
 
     /* Function pointers.  */
     ._dl_debug_printf = _dl_debug_printf,
@@ -969,6 +970,13 @@ dl_main (const ElfW(Phdr) *phdr,
          {
            mode = verify;
 
+           ++_dl_skip_args;
+           --_dl_argc;
+           ++INTUSE(_dl_argv);
+         }
+       else if (! strcmp (INTUSE(_dl_argv)[1], "--inhibit-cache"))
+         {
+           GLRO(dl_inhibit_cache) = 1;
            ++_dl_skip_args;
            --_dl_argc;
            ++INTUSE(_dl_argv);
@@ -1022,6 +1030,7 @@ of this helper program; chances are you did not intend to run this program.\n\
   --list                list all dependencies and how they are resolved\n\
   --verify              verify that given object really is a dynamically linked\n\
                        object we can handle\n\
+  --inhibit-cache       Do not use " LD_SO_CACHE "\n\
   --library-path PATH   use given PATH instead of content of the environment\n\
                        variable LD_LIBRARY_PATH\n\
   --inhibit-rpath LIST  ignore RUNPATH and RPATH information in object names\n\
index 9955430e3c37aa0f0d5d96877bbaa2b202812d39..602b429cea484e18593d4a095a85a1b98753f015 100644 (file)
@@ -1,5 +1,5 @@
 /* Run-time dynamic linker data structures for loaded ELF shared objects.
-   Copyright (C) 1995-2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -560,6 +560,9 @@ struct rtld_global_ro
   /* Cached value of `getpagesize ()'.  */
   EXTERN size_t _dl_pagesize;
 
+  /* Do we read from ld.so.cache?  */
+  EXTERN int _dl_inhibit_cache;
+
   /* Copy of the content of `_dl_main_searchlist' at startup time.  */
   EXTERN struct r_scope_elem _dl_initial_searchlist;
 
This page took 0.066259 seconds and 5 git commands to generate.