diff options
author | Serhey Popovych <serhe.popovych@gmail.com> | 2018-12-14 19:54:35 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-15 17:10:52 +0000 |
commit | 6be12c06228cf7c686f16d21eba178e9437e1e65 (patch) | |
tree | 71fbfe04634cc8822b1df7470377a5060407571b /meta/recipes-core | |
parent | 2468becd4bac45d2893eba8c322203874c48e27a (diff) | |
download | poky-6be12c06228cf7c686f16d21eba178e9437e1e65.tar.gz |
musl: Create default library search path based on configuration
In absence of /etc/ld-musl-$(ARCH).path file musl uses hardcoded default
search path "/lib:/usr/local/lib:/usr/lib". This works for cases when
system libraries installed in one of these pathes.
However if lib64 or libx32 used as system library directories and no
usr merge functionality enabled for distro musl dynamic loader cannot
find libraries and finally execute binaries.
Found while working on support for musl on powerpc64 builds where
lib64 variant is used regardless of multilib being on or off.
Fix by creating default search path based on configuration time values
for syslibdir and libdir.
(From OE-Core rev: 2da79f021b5525ea5b56a86563905a67fc958fa5)
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r-- | meta/recipes-core/musl/musl/0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch | 61 | ||||
-rw-r--r-- | meta/recipes-core/musl/musl_git.bb | 1 |
2 files changed, 62 insertions, 0 deletions
diff --git a/meta/recipes-core/musl/musl/0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch b/meta/recipes-core/musl/musl/0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch new file mode 100644 index 0000000000..6a875a717e --- /dev/null +++ b/meta/recipes-core/musl/musl/0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch | |||
@@ -0,0 +1,61 @@ | |||
1 | From 5a2886f81dbca3f2ed28eebe7d27d471da278db8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Serhey Popovych <serhe.popovych@gmail.com> | ||
3 | Date: Tue, 11 Dec 2018 05:44:20 -0500 | ||
4 | Subject: [PATCH] ldso: Use syslibdir and libdir as default pathes to libdirs | ||
5 | |||
6 | In absence of /etc/ld-musl-$(ARCH).path ldso uses default path to search | ||
7 | libraries /lib:/usr/local/lib:/usr/lib. | ||
8 | |||
9 | However this path isn't relevant in case when library is put in dirs | ||
10 | like lib64 or libx32. | ||
11 | |||
12 | Adjust CFLAGS_ALL to pass syslibdir as SYSLIBDIR and libdir as LIBDIR | ||
13 | preprocessor macroses to construct default ldso library search path | ||
14 | in ldso/dynlink.c::SYS_PATH_DFLT. | ||
15 | |||
16 | Upstream-Status: Pending | ||
17 | Signed-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 | |||
23 | diff --git a/Makefile b/Makefile | ||
24 | index b46f8ca4..c07e4ae8 100644 | ||
25 | --- a/Makefile | ||
26 | +++ b/Makefile | ||
27 | @@ -46,7 +46,8 @@ CFLAGS_AUTO = -Os -pipe | ||
28 | CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc | ||
29 | |||
30 | CFLAGS_ALL = $(CFLAGS_C99FSE) | ||
31 | -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 | ||
32 | +CFLAGS_ALL += -D_XOPEN_SOURCE=700 -DSYSLIBDIR='"$(syslibdir)"' -DLIBDIR='"$(libdir)"' | ||
33 | +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 | ||
34 | CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS) | ||
35 | |||
36 | LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS) | ||
37 | diff --git a/ldso/dynlink.c b/ldso/dynlink.c | ||
38 | index ec921dfd..7c119c55 100644 | ||
39 | --- a/ldso/dynlink.c | ||
40 | +++ b/ldso/dynlink.c | ||
41 | @@ -22,6 +22,8 @@ | ||
42 | #include "dynlink.h" | ||
43 | #include "malloc_impl.h" | ||
44 | |||
45 | +#define SYS_PATH_DFLT SYSLIBDIR ":" LIBDIR | ||
46 | + | ||
47 | static void error(const char *, ...); | ||
48 | |||
49 | #define MAXP2(a,b) (-(-(a)&-(b))) | ||
50 | @@ -1038,7 +1040,7 @@ static struct dso *load_library(const char *name, struct dso *needed_by) | ||
51 | sys_path = ""; | ||
52 | } | ||
53 | } | ||
54 | - if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib"; | ||
55 | + if (!sys_path) sys_path = SYS_PATH_DFLT; | ||
56 | fd = path_open(name, sys_path, buf, sizeof buf); | ||
57 | } | ||
58 | pathname = buf; | ||
59 | -- | ||
60 | 2.7.4 | ||
61 | |||
diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb index b416ec45bf..9cc875c4a6 100644 --- a/meta/recipes-core/musl/musl_git.bb +++ b/meta/recipes-core/musl/musl_git.bb | |||
@@ -12,6 +12,7 @@ PV = "1.1.20+git${SRCPV}" | |||
12 | 12 | ||
13 | SRC_URI = "git://git.musl-libc.org/musl \ | 13 | SRC_URI = "git://git.musl-libc.org/musl \ |
14 | file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \ | 14 | file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \ |
15 | file://0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch \ | ||
15 | " | 16 | " |
16 | 17 | ||
17 | S = "${WORKDIR}/git" | 18 | S = "${WORKDIR}/git" |