[PATCH 1/3] New --inhibit-ldcache option to ld.so to prevent it form reading ld.so.cache

Siddhesh Poyarekar siddhesh@redhat.com
Fri Apr 6 14:48:00 GMT 2012


Hi,

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.

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

To test the patch:

1) Write two simple programs, one for the binary and another for a
library:

echo "int main () {return libbar();}" > foo.c
echo "int libbar(void) {return 42;}" > bar.c
gcc -o libbar.so -shared -fPIC bar.c
gcc -o foo foo.c -L. -lbar

Now move libbar.so to a non-standard library path, add its reference
to ${prefix}/etc/ld.so.conf and run ldconfig.

Run without --inhibit-ldcache:

${prefix}/lib/ld-2.15.90.so --library-path=${prefix}/lib ./foo

Run with --inhibit-ldcache:

${prefix}/lib/ld-2.15.90.so --library-path=${prefix}/lib \
--inhibit-ldcache ./foo

Notice that the latter case throws up an error saying that libbar.so
was not found.

Regards,
Siddhesh

ChangeLog:

2012-04-06  Siddhesh Poyarekar  <siddhesh@redhat.com>

	* elf/dl-support.c (_dl_inhibit_ldcache): New variable.
	* elf/rtld.c (_rtld_global_ro): New member
	_dl_inhibit_ldcache. (dl_main): Handle --inhibit-ldcache.
	* sysdeps/generic/ldsodefs.h (struct rtld_global_ro): New
	member _dl_inhibit_ldcache.
	* elf/dl-load.c (_dl_map_object): Use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-inhibit-cache.patch
Type: text/x-patch
Size: 2930 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120406/f30c6089/attachment.bin>


More information about the Libc-alpha mailing list