blob: 59bfae5a27c5138647ed4090bc894c224f599b26 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From 3cce8716c6c3ae2e0c835caeac3780ec35090b2d Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: Serhey Popovych <serhe.popovych@gmail.com>
3Date: Tue, 11 Dec 2018 05:44:20 -0500
Patrick Williams92b42cb2022-09-03 06:53:57 -05004Subject: [PATCH 2/2] ldso: Use syslibdir and libdir as default pathes to
5 libdirs
Brad Bishop19323692019-04-05 15:28:33 -04006
7In absence of /etc/ld-musl-$(ARCH).path ldso uses default path to search
8libraries /lib:/usr/local/lib:/usr/lib.
9
10However this path isn't relevant in case when library is put in dirs
11like lib64 or libx32.
12
13Adjust CFLAGS_ALL to pass syslibdir as SYSLIBDIR and libdir as LIBDIR
14preprocessor macroses to construct default ldso library search path
15in ldso/dynlink.c::SYS_PATH_DFLT.
16
17Upstream-Status: Pending
18Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
19---
20 Makefile | 3 ++-
21 ldso/dynlink.c | 4 +++-
22 2 files changed, 5 insertions(+), 2 deletions(-)
23
Patrick Williams92b42cb2022-09-03 06:53:57 -050024diff --git a/Makefile b/Makefile
25index 466d9afd..d2f458fa 100644
Brad Bishop19323692019-04-05 15:28:33 -040026--- a/Makefile
27+++ b/Makefile
Andrew Geissler475cb722020-07-10 16:00:51 -050028@@ -47,7 +47,8 @@ CFLAGS_AUTO = -Os -pipe
Brad Bishop19323692019-04-05 15:28:33 -040029 CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
30
31 CFLAGS_ALL = $(CFLAGS_C99FSE)
32-CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
33+CFLAGS_ALL += -D_XOPEN_SOURCE=700 -DSYSLIBDIR='"$(syslibdir)"' -DLIBDIR='"$(libdir)"'
34+CFLAGS_ALL += -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/include -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
35 CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
36
37 LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
Patrick Williams92b42cb2022-09-03 06:53:57 -050038diff --git a/ldso/dynlink.c b/ldso/dynlink.c
39index cc677952..b0e8815b 100644
Brad Bishop19323692019-04-05 15:28:33 -040040--- a/ldso/dynlink.c
41+++ b/ldso/dynlink.c
Andrew Geisslerd1e89492021-02-12 15:35:20 -060042@@ -29,6 +29,8 @@
43 #define realloc __libc_realloc
44 #define free __libc_free
Brad Bishop19323692019-04-05 15:28:33 -040045
46+#define SYS_PATH_DFLT SYSLIBDIR ":" LIBDIR
47+
Patrick Williams92b42cb2022-09-03 06:53:57 -050048 static void error_impl(const char *, ...);
49 static void error_noop(const char *, ...);
50 static void (*error)(const char *, ...) = error_noop;
51@@ -1097,7 +1099,7 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
Brad Bishop19323692019-04-05 15:28:33 -040052 sys_path = "";
53 }
54 }
55- if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib";
56+ if (!sys_path) sys_path = SYS_PATH_DFLT;
57 fd = path_open(name, sys_path, buf, sizeof buf);
58 }
59 pathname = buf;
Patrick Williams92b42cb2022-09-03 06:53:57 -050060--
612.37.2
62