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 <sti...@att.net>
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 <sti...@att.net>
---
 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

_______________________________________________
devel mailing list
devel@uclibc-ng.org
https://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel

Reply via email to