From patchwork Fri Feb 6 20:56:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 437458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id C32681401DA for ; Sat, 7 Feb 2015 07:57:01 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B9BD78CF34; Fri, 6 Feb 2015 20:56:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TVDKO2VaPhBc; Fri, 6 Feb 2015 20:56:57 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 680E18CBAC; Fri, 6 Feb 2015 20:56:57 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 837541C1081 for ; Fri, 6 Feb 2015 20:56:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7ED2A931CC for ; Fri, 6 Feb 2015 20:56:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u1gIoyTHfalS for ; Fri, 6 Feb 2015 20:56:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by hemlock.osuosl.org (Postfix) with ESMTP id 4BE23931C2 for ; Fri, 6 Feb 2015 20:56:55 +0000 (UTC) Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 60CA5CB5EC129; Fri, 6 Feb 2015 20:56:49 +0000 (GMT) Received: from BAMAIL02.ba.imgtec.org (10.20.40.28) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 6 Feb 2015 20:56:52 +0000 Received: from [10.20.3.58] (10.20.3.58) by bamail02.ba.imgtec.org (10.20.40.28) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 6 Feb 2015 12:56:44 -0800 Message-ID: <1423256191.27046.7.camel@ubuntu-sellcey> Subject: Re: executable RPATH question From: Steve Ellcey To: Waldemar Brodkorb Date: Fri, 6 Feb 2015 12:56:31 -0800 In-Reply-To: <20150206072327.GW27501@waldemar-brodkorb.de> References: <5e89a632-f471-46f8-bae8-f2aa5cb10ee4@BAMAIL02.ba.imgtec.org> <20150206072327.GW27501@waldemar-brodkorb.de> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-Originating-IP: [10.20.3.58] Cc: uclibc@uclibc.org X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sellcey@imgtec.com Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" On Fri, 2015-02-06 at 08:23 +0100, Waldemar Brodkorb wrote: > Hi Steve, > > > > Original discussion: > > > > http://lists.uclibc.org/pipermail/uclibc/2011-September/045757.html > > Do you have a patch which applies to master? > Including an option... > > best regards > Waldemar Here is a patch that I came up with the includes an option (off by default). Steve Ellcey sellcey@imgtec.com diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index 8e603b2..a235c3d 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -418,6 +418,15 @@ config LDSO_RUNPATH Usage of RUNPATH tags is not too common, so disabling this feature should be safe for most people. +config LDSO_RUNPATH_OF_EXECUTABLE + bool "Use executables RPATH/RUNPATH when searching for libraries." + depends on LDSO_RUNPATH + default n + help + Use the executables RPATH/RUNPATH to find to find libraries even + though this behavour is not standard. Setting this option causes + the uclibc dynamic linker behavour to match the glibc dynamic linker. + config LDSO_SAFE_RUNPATH bool "Allow only RUNPATH beginning with /" depends on LDSO_RUNPATH diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 54501d1..56076b6 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -237,6 +237,18 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL) return tpnt1; } +#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__ + /* + * Try the DT_RPATH of the executable itself. + */ + pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH]; + if (pnt) { + pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB]; + _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", pnt); + if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL) + return tpnt1; + } +#endif #endif #ifdef __LDSO_LD_LIBRARY_PATH__