From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5057 invoked by alias); 10 Oct 2002 14:22:05 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 5038 invoked from network); 10 Oct 2002 14:22:04 -0000 Received: from unknown (HELO sunsite.mff.cuni.cz) (195.113.19.66) by sources.redhat.com with SMTP; 10 Oct 2002 14:22:04 -0000 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.11.6/8.11.6) id g9AELuA29381; Thu, 10 Oct 2002 16:21:56 +0200 Date: Thu, 10 Oct 2002 23:42:00 -0000 From: Jakub Jelinek To: Roland McGrath , Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Honor executables DT_RUNPATH for dlopen Message-ID: <20021010162155.Y3451@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-SW-Source: 2002-10/txt/msg00049.txt.bz2 Hi! echo 'void f () {}' | gcc -fpic -shared -xc - -o libbar.so gcc -Wl,-rpath,.,--enable-new-dtags -xc - -ldl -o bar <<"EOF" #include 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 * 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