aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/0001-nativesdk-glibc-Look-for-host-system-ld.so.cache-as-.patch
blob: 3d6634813362946cb81624d2d80aad477b6803ac (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
From 0876fea1b5b26da84f298714a2e23ba696607dba Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 18 Mar 2015 01:48:24 +0000
Subject: [PATCH 01/27] nativesdk-glibc: Look for host system ld.so.cache as
 well

Upstream-Status: Inappropriate [embedded specific]

The default lib search path order is:

  1) LD_LIBRARY_PATH
  2) RPATH from the binary
  3) ld.so.cache
  4) default search paths embedded in the linker

For nativesdk binaries which are being used alongside binaries on a host system, we
need the search paths to firstly search the shipped nativesdk libs but then also
cover the host system. For example we want the host system's libGL and this may be
in a non-standard location like /usr/lib/mesa. The only place the location is know
about is in the ld.so.cache of the host system.

Since nativesdk has a simple structure and doesn't need to use a cache itself, we
repurpose the cache for use as a last resort in finding host system binaries. This
means we need to switch the order of 3 and 4 above to make this work effectively.

RP 14/10/2010

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 elf/dl-load.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 0c052e4..f45085a 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -2040,7 +2040,14 @@ _dl_map_object (struct link_map *loader, const char *name,
 	fd = open_path (name, namelen, mode,
 			&loader->l_runpath_dirs, &realname, &fb, loader,
 			LA_SER_RUNPATH, &found_other_class);
-
+      /* try the default path.  */
+      if (fd == -1
+	  && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
+	   || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
+	 && rtld_search_dirs.dirs != (void *) -1)
+	fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs,
+			&realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
+      /* Finally try ld.so.cache */
 #ifdef USE_LDCONFIG
       if (fd == -1
 	  && (__glibc_likely ((mode & __RTLD_SECURE) == 0)
@@ -2099,14 +2106,6 @@ _dl_map_object (struct link_map *loader, const char *name,
 	}
 #endif
 
-      /* Finally, try the default path.  */
-      if (fd == -1
-	  && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
-	      || __glibc_likely (!(l->l_flags_1 & DF_1_NODEFLIB)))
-	  && rtld_search_dirs.dirs != (void *) -1)
-	fd = open_path (name, namelen, mode, &rtld_search_dirs,
-			&realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
-
       /* Add another newline when we are tracing the library loading.  */
       if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
 	_dl_debug_printf ("\n");
-- 
2.1.4