summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/musl/musl/0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch
blob: 8b097f32768b2711e480d19baf28a580d2f065a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From f95b6fd0475a95c00e886219271cb5c93838e3c3 Mon Sep 17 00:00:00 2001
From: Amarnath Valluri <amarnath.valluri@intel.com>
Date: Wed, 18 Jan 2017 16:14:37 +0200
Subject: [PATCH 1/2] Make dynamic linker a relative symlink to libc

absolute symlink into $(libdir) fails to load in a cross build
environment, especially when executing qemu in usermode to run target
applications, which cross build systems often do, since not everything
can be computed during cross builds, qemu in usermode often comes to aid
in such situations to feed into cross builds.

V2:
 Make use of 'ln -r' to create relative symlinks, as most fo the distros
 shipping coreutils 8.16+

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
---
 Makefile         | 2 +-
 tools/install.sh | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index e8cc4436..466d9afd 100644
--- a/Makefile
+++ b/Makefile
@@ -210,7 +210,7 @@ $(DESTDIR)$(includedir)/%: $(srcdir)/include/%
 	$(INSTALL) -D -m 644 $< $@
 
 $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so
-	$(INSTALL) -D -l $(libdir)/libc.so $@ || true
+	$(INSTALL) -D -r $(DESTDIR)$(libdir)/libc.so $@ || true
 
 install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)
 
diff --git a/tools/install.sh b/tools/install.sh
index d913b60b..b6a7f797 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -6,18 +6,20 @@
 #
 
 usage() {
-printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2
+printf "usage: %s [-D] [-l] [-r] [-m mode] src dest\n" "$0" 1>&2
 exit 1
 }
 
 mkdirp=
 symlink=
+symlinkflags="-s"
 mode=755
 
-while getopts Dlm: name ; do
+while getopts Dlrm: name ; do
 case "$name" in
 D) mkdirp=yes ;;
 l) symlink=yes ;;
+r) symlink=yes; symlinkflags="$symlinkflags -r" ;;
 m) mode=$OPTARG ;;
 ?) usage ;;
 esac
@@ -48,7 +50,7 @@ trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP
 umask 077
 
 if test "$symlink" ; then
-ln -s "$1" "$tmp"
+ln $symlinkflags "$1" "$tmp"
 else
 cat < "$1" > "$tmp"
 chmod "$mode" "$tmp"
-- 
2.37.2