public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Honor executables DT_RUNPATH for dlopen
@ 2002-10-10 23:42 Jakub Jelinek
  2002-11-05 20:04 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2002-10-10 23:42 UTC (permalink / raw)
  To: Roland McGrath, Ulrich Drepper; +Cc: Glibc hackers

Hi!

echo 'void f () {}' | gcc -fpic -shared -xc - -o libbar.so
gcc -Wl,-rpath,.,--enable-new-dtags -xc - -ldl -o bar <<"EOF"
#include <dlfcn.h>

int main () {
  void *p = dlopen ("libbar.so", RTLD_NOW);
  if (!p)
    puts (dlerror ());
  return !p;
}
EOF
./bar

test fails, because for dlopen DT_RUNPATH of the executable is not searched.
Unfortunately the patch does a bunch of tests in the common path, maybe
it should be reordered to check l->l_runpath_dirs.dirs != -1 right before
l->l_type != lt_loaded test.

2002-10-10  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-load.c (_dl_map_object): Use DT_RUNPATH of the executable
	for dlopen searches.

--- libc/elf/dl-load.c.jj	2002-10-10 13:57:28.000000000 +0200
+++ libc/elf/dl-load.c	2002-10-10 13:59:20.000000000 +0200
@@ -1751,6 +1751,14 @@ _dl_map_object (struct link_map *loader,
 	  break;
 	}
 
+      /* If dynamically linked, try the DT_RUNPATH of the executable
+	 itself.  */
+      l = GL(dl_loaded);
+      if (fd == -1 && l && l->l_type != lt_loaded && l != loader
+	  && l->l_runpath_dirs.dirs != (void *) -1)
+	fd = open_path (name, namelen, preloaded, &l->l_runpath_dirs,
+			&realname, &fb);
+
       if (fd == -1
 	  && (__builtin_expect (! preloaded, 1)
 	      || ! INTUSE(__libc_enable_secure)))

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-06  4:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-10 23:42 [PATCH] Honor executables DT_RUNPATH for dlopen Jakub Jelinek
2002-11-05 20:04 ` Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).