From 8738e7f8b0c6d6254a31450dc528bddc8bdae0f7 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 16 Nov 1995 02:37:06 +0000 Subject: * elf/dl-lookup.c (_dl_lookup_symbol): Undefined symbol is no error if weak. * elf/Makefile (default-rpath): New variable. (CPPFLAGS): Append -DDEFAULT_RPATH=.... * elf/dl-load.c (_dl_map_object): Use DEFAULT_RPATH instead of hard-coded "/lib:/usr/lib". --- elf/Makefile | 10 ++++++++++ elf/dl-load.c | 2 +- elf/dl-lookup.c | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'elf') diff --git a/elf/Makefile b/elf/Makefile index 08288f89d5..a37e95d2c5 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -50,6 +50,16 @@ endif include ../Rules +# Choose the default search path for the dynamic linker based on +# where we will install libraries. +ifneq ($(libdir),$(slibdir)) +default-rpath = $(slibdir):$(libdir) +else +default-rpath = $(libdir) +endif +CPPFLAGS += -DDEFAULT_RPATH='"$(default-rpath)"' + + # Link together the dynamic linker into a single relocatable object. # We use this to produce both the ABI-compliant and Linux-compatible # dynamic linker shared objects below. diff --git a/elf/dl-load.c b/elf/dl-load.c index b70ba5590a..126d6aab5c 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -139,7 +139,7 @@ _dl_map_object (struct link_map *loader, const char *name) if (fd == -1 && ! _dl_secure) trypath (getenv ("LD_LIBRARY_PATH")); if (fd == -1) - trypath ("/lib:/usr/lib"); + trypath (DEFAULT_RPATH); } else { diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c index 62802ddea7..cb337d47cd 100644 --- a/elf/dl-lookup.c +++ b/elf/dl-lookup.c @@ -22,7 +22,7 @@ Cambridge, MA 02139, USA. */ #include #include -/* Search loaded objects' symbol tables for a definition of +/* Search loaded objects' symbol tables for a definition of the symbol UNDEF_NAME. If NOSELF is nonzero, then *REF cannot satisfy the reference itself; some different binding must be found. */ @@ -100,7 +100,7 @@ _dl_lookup_symbol (const char *undef_name, const Elf32_Sym **ref, } } - if (weak_value.s == NULL) + if (weak_value.s == NULL && ELF32_ST_BIND ((*ref)->st_info) != STB_WEAK) { const char msg[] = "undefined symbol: "; char buf[sizeof msg + strlen (undef_name)]; -- cgit 1.4.1