blob: f57aae5f3ca136996ab8317fac0624058743d27e [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 5a2886f81dbca3f2ed28eebe7d27d471da278db8 Mon Sep 17 00:00:00 2001
2From: Serhey Popovych <serhe.popovych@gmail.com>
3Date: Tue, 11 Dec 2018 05:44:20 -0500
4Subject: [PATCH] ldso: Use syslibdir and libdir as default pathes to libdirs
5
6In absence of /etc/ld-musl-$(ARCH).path ldso uses default path to search
7libraries /lib:/usr/local/lib:/usr/lib.
8
9However this path isn't relevant in case when library is put in dirs
10like lib64 or libx32.
11
12Adjust CFLAGS_ALL to pass syslibdir as SYSLIBDIR and libdir as LIBDIR
13preprocessor macroses to construct default ldso library search path
14in ldso/dynlink.c::SYS_PATH_DFLT.
15
16Upstream-Status: Pending
17Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
18---
19 Makefile | 3 ++-
20 ldso/dynlink.c | 4 +++-
21 2 files changed, 5 insertions(+), 2 deletions(-)
22
Brad Bishop19323692019-04-05 15:28:33 -040023--- a/Makefile
24+++ b/Makefile
Andrew Geissler475cb722020-07-10 16:00:51 -050025@@ -47,7 +47,8 @@ CFLAGS_AUTO = -Os -pipe
Brad Bishop19323692019-04-05 15:28:33 -040026 CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
27
28 CFLAGS_ALL = $(CFLAGS_C99FSE)
29-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
30+CFLAGS_ALL += -D_XOPEN_SOURCE=700 -DSYSLIBDIR='"$(syslibdir)"' -DLIBDIR='"$(libdir)"'
31+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
32 CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
33
34 LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
Brad Bishop19323692019-04-05 15:28:33 -040035--- a/ldso/dynlink.c
36+++ b/ldso/dynlink.c
Andrew Geissler706d5aa2021-02-12 15:55:30 -060037@@ -24,6 +24,8 @@
38 #include "libc.h"
39 #include "dynlink.h"
Brad Bishop19323692019-04-05 15:28:33 -040040
41+#define SYS_PATH_DFLT SYSLIBDIR ":" LIBDIR
42+
43 static void error(const char *, ...);
44
45 #define MAXP2(a,b) (-(-(a)&-(b)))
Andrew Geissler706d5aa2021-02-12 15:55:30 -060046@@ -1071,7 +1073,7 @@ static struct dso *load_library(const ch
Brad Bishop19323692019-04-05 15:28:33 -040047 sys_path = "";
48 }
49 }
50- if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib";
51+ if (!sys_path) sys_path = SYS_PATH_DFLT;
52 fd = path_open(name, sys_path, buf, sizeof buf);
53 }
54 pathname = buf;