Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | From 3cce8716c6c3ae2e0c835caeac3780ec35090b2d Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 2 | From: Serhey Popovych <serhe.popovych@gmail.com> |
| 3 | Date: Tue, 11 Dec 2018 05:44:20 -0500 |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 4 | Subject: [PATCH 2/2] ldso: Use syslibdir and libdir as default pathes to |
| 5 | libdirs |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 6 | |
| 7 | In absence of /etc/ld-musl-$(ARCH).path ldso uses default path to search |
| 8 | libraries /lib:/usr/local/lib:/usr/lib. |
| 9 | |
| 10 | However this path isn't relevant in case when library is put in dirs |
| 11 | like lib64 or libx32. |
| 12 | |
| 13 | Adjust CFLAGS_ALL to pass syslibdir as SYSLIBDIR and libdir as LIBDIR |
| 14 | preprocessor macroses to construct default ldso library search path |
| 15 | in ldso/dynlink.c::SYS_PATH_DFLT. |
| 16 | |
| 17 | Upstream-Status: Pending |
| 18 | Signed-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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 24 | diff --git a/Makefile b/Makefile |
| 25 | index 466d9afd..d2f458fa 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 26 | --- a/Makefile |
| 27 | +++ b/Makefile |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 28 | @@ -47,7 +47,8 @@ CFLAGS_AUTO = -Os -pipe |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 38 | diff --git a/ldso/dynlink.c b/ldso/dynlink.c |
| 39 | index cc677952..b0e8815b 100644 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 40 | --- a/ldso/dynlink.c |
| 41 | +++ b/ldso/dynlink.c |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 42 | @@ -29,6 +29,8 @@ |
| 43 | #define realloc __libc_realloc |
| 44 | #define free __libc_free |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 45 | |
| 46 | +#define SYS_PATH_DFLT SYSLIBDIR ":" LIBDIR |
| 47 | + |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 48 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 52 | 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 60 | -- |
| 61 | 2.37.2 |
| 62 | |