From patchwork Wed Mar 15 06:30:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Neyman X-Patchwork-Id: 739033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vjhYd29Cgz9s1h for ; Wed, 15 Mar 2017 17:30:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=att.net header.i=@att.net header.b="yZdKoGst"; dkim-atps=neutral Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 9596C10084; Wed, 15 Mar 2017 07:30:23 +0100 (CET) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from nm6-vm7.access.bullet.mail.bf1.yahoo.com (nm6-vm7.access.bullet.mail.bf1.yahoo.com [216.109.114.150]) by helium.openadk.org (Postfix) with ESMTPS id 904C310084 for ; Wed, 15 Mar 2017 07:30:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024; t=1489559419; bh=xYfRcoTKvvlOXyYOrKrntisY+HUTnyhcmklXuamgQc8=; h=To:From:Subject:Date:From:Subject; b=yZdKoGst8wjfGg177mpoCEHbY4NobOgloBI2rQJ18rcj4kYYeEPH9kKO7bF2zu1IFpUmaKXISrweP17DVqgwDshWVdkalR2emvU1mzcoJdXiHio29Vr4j1XoT8cdRmUBw1VDIelgQmNhUx5+bY4mI2R5bNr5GE+m/i7jSlqov/8= Received: from [66.196.81.165] by nm6.access.bullet.mail.bf1.yahoo.com with NNFMP; 15 Mar 2017 06:30:19 -0000 Received: from [98.138.104.100] by tm11.access.bullet.mail.bf1.yahoo.com with NNFMP; 15 Mar 2017 06:30:19 -0000 Received: from [127.0.0.1] by smtp120.sbc.mail.ne1.yahoo.com with NNFMP; 15 Mar 2017 06:30:19 -0000 X-Yahoo-Newman-Id: 493377.12062.bm@smtp120.sbc.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: ynNm8skVM1lRVAk8mSvI5g9s7X4DeX_zxNdZHufsMrGrroK UhGvt0BW_ynt67CIKoTkedQ5gpPk.ydPghT.vDdeo3aumPErt.6GWBVohdd0 DgcpXbYwik049z7VmAsuZ325S6cUqjq9qXo2iAlCHNq5DShf9csbD9udgOFv fGVr.mFKUGi615oWqwRHvsxTpixUaF6DvtqtINIJW1R2.LM_jmMEoh0jJXeW u0DkrZOVBY34jeggx4P0.xEseyO1lPigpmO3jt1P_wVEco.XRcW7.60Jxh3a Beyb80O4xb8ur1ONBq7ClkFSCtOXp7z0ECadrZtYW_xr7qnBMbWpw6z4nCPq vJXIX8n7nnshsX6dVVqm_aU4_PPfOsxg..rHuXfdCvOsp.2rW0bTmnxtgT4c jb5RMeP_7PX7F8Qk5RWvWIeIcQJpv3PohnFxTFvQBXomg0IltusDqndivr.Z uiOlDAJ1_zkEOsOZD4LXaEtTfekryOKe_u4LgRe85PGUr6xdT7.buC6DYXIw y9sRPSZaQMdjiHe_s10tgfBPGMhPsi3946BNpqDQ5Wt2k1hIisXZsQq7peDS 5e0I2 X-Yahoo-SMTP: 0h0Q7euswBD_g.kcEqbzJWRFfrba801gq1M1 To: Waldemar Brodkorb , devel@uclibc-ng.org From: Alexey Neyman Message-ID: Date: Tue, 14 Mar 2017 23:30:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Subject: [uclibc-ng-devel] Search configured multilib dir for shared libraries X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" Hi, With uClibc-ng configured with "lib64" multilib prefix, ld.so does not search /lib64:/usr/lib64 for the dynamic libraries because both _dl_library_path and the ld.so install path point to /lib (yes, uClibc-ng installs its linker to /lib64 - but gcc insists on using /lib/ld-uClibc-x86-64.so.0, not /lib64). Not included in this patch are changes for ldd - I guess it needs similar changes. Also, it looks like dl-elf.c could benefit from some cleanup - for example, DT_RUNPATH is searched twice, once before LD_LIBRARY_PATH and once after. Regards, Alexey. From f030d2263276243e0ed8baad67e583bf5037bce9 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 14 Mar 2017 23:24:14 -0700 Subject: [PATCH] Search the configured multilib ... before falling back to ld.so installation path (it is not the same - gcc uses /lib/ld-uClibc-x86-64.so.0 for uClibc) or default /lib:/usr/lib. This matches glibc behavior (see trusted-dirs.h generated during glibc build). Signed-off-by: Alexey Neyman --- ldso/ldso/Makefile.in | 5 +++++ ldso/ldso/dl-elf.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in index 993aeb9..320e448 100644 --- a/ldso/ldso/Makefile.in +++ b/ldso/ldso/Makefile.in @@ -34,6 +34,11 @@ CFLAGS-$(DODEBUG)-ldso/ldso := -O2 -g CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" +# Search non-default multilib directories +ifneq ($(MULTILIB_DIR),lib) +CFLAGS-ldso.c += -DLDSO_MULTILIB_DIR=\"$(MULTILIB_DIR)\" +endif + ifeq ($(TARGET_ARCH),arc) CFLAGS-ldso.c += -mno-long-calls endif diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index a046aeb..4b3d86e 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -307,6 +307,19 @@ struct elf_resolve *_dl_load_shared_library(unsigned int rflags, struct dyn_elf } } #endif + +#ifdef LDSO_MULTILIB_DIR + /* If multilib directory is selected, search it before falling back to + standard lib directories. */ + _dl_if_debug_dprint("\tsearching multilib lib path list\n"); + tpnt1 = search_for_named_library(libname, rflags, + UCLIBC_RUNTIME_PREFIX LDSO_MULTILIB_DIR ":" + UCLIBC_RUNTIME_PREFIX "usr" LDSO_MULTILIB_DIR, + rpnt, NULL); + if (tpnt1 != NULL) + return tpnt1; +#endif + #if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__ /* Look for libraries wherever the shared library loader * was installed */ @@ -315,6 +328,7 @@ struct elf_resolve *_dl_load_shared_library(unsigned int rflags, struct dyn_elf if (tpnt1 != NULL) return tpnt1; #endif + /* Lastly, search the standard list of paths for the library. This list must exactly match the list in uClibc/ldso/util/ldd.c */ _dl_if_debug_dprint("\tsearching full lib path list\n"); -- 2.9.3