summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/uclibc/uclibc-git/orign_path.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/uclibc/uclibc-git/orign_path.patch')
-rw-r--r--meta/recipes-core/uclibc/uclibc-git/orign_path.patch186
1 files changed, 186 insertions, 0 deletions
diff --git a/meta/recipes-core/uclibc/uclibc-git/orign_path.patch b/meta/recipes-core/uclibc/uclibc-git/orign_path.patch
new file mode 100644
index 0000000..81bb8f8
--- /dev/null
+++ b/meta/recipes-core/uclibc/uclibc-git/orign_path.patch
@@ -0,0 +1,186 @@
1Patch is backported from
2http://lists.busybox.net/pipermail/uclibc/2011-March/045003.html
3
4Upstream-Status: Pending
5
6Index: git/ldso/ldso/dl-elf.c
7===================================================================
8--- git.orig/ldso/ldso/dl-elf.c 2012-06-19 18:29:08.629931662 -0700
9+++ git/ldso/ldso/dl-elf.c 2012-06-19 21:21:14.798431393 -0700
10@@ -133,56 +133,60 @@
11 * in uClibc/ldso/util/ldd.c */
12 static struct elf_resolve *
13 search_for_named_library(const char *name, unsigned rflags, const char *path_list,
14- struct dyn_elf **rpnt)
15+ struct dyn_elf **rpnt, const char* origin)
16 {
17- char *path, *path_n, *mylibname;
18+ char *mylibname;
19 struct elf_resolve *tpnt;
20- int done;
21+ const char *p, *pn;
22+ int plen;
23
24 if (path_list==NULL)
25 return NULL;
26
27- /* We need a writable copy of this string, but we don't
28- * need this allocated permanently since we don't want
29- * to leak memory, so use alloca to put path on the stack */
30- done = _dl_strlen(path_list);
31- path = alloca(done + 1);
32-
33 /* another bit of local storage */
34 mylibname = alloca(2050);
35
36- _dl_memcpy(path, path_list, done+1);
37-
38 /* Unlike ldd.c, don't bother to eliminate double //s */
39
40 /* Replace colons with zeros in path_list */
41 /* : at the beginning or end of path maps to CWD */
42 /* :: anywhere maps CWD */
43 /* "" maps to CWD */
44- done = 0;
45- path_n = path;
46- do {
47- if (*path == 0) {
48- *path = ':';
49- done = 1;
50+ for (p = path_list; p != NULL; p = pn) {
51+ pn = _dl_strchr(p + 1, ':');
52+ if (pn != NULL) {
53+ plen = pn - p;
54+ pn++;
55+ } else
56+ plen = _dl_strlen(p);
57+
58+ if (plen >= 7 && _dl_memcmp(p, "$ORIGIN", 7) == 0) {
59+ int olen;
60+ if (rflags && plen != 7)
61+ continue;
62+ if (origin == NULL)
63+ continue;
64+ for (olen = _dl_strlen(origin) - 1; olen >= 0 && origin[olen] != '/'; olen--)
65+ ;
66+ if (olen <= 0)
67+ continue;
68+ _dl_memcpy(&mylibname[0], origin, olen);
69+ _dl_memcpy(&mylibname[olen], p + 7, plen - 7);
70+ mylibname[olen + plen - 7] = 0;
71+ } else if (plen != 0) {
72+ _dl_memcpy(mylibname, p, plen);
73+ mylibname[plen] = 0;
74+ } else {
75+ _dl_strcpy(mylibname, ".");
76 }
77- if (*path == ':') {
78- *path = 0;
79- if (*path_n)
80- _dl_strcpy(mylibname, path_n);
81- else
82- _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */
83- _dl_strcat(mylibname, "/");
84- _dl_strcat(mylibname, name);
85+ _dl_strcat(mylibname, "/");
86+ _dl_strcat(mylibname, name);
87 #ifdef __LDSO_SAFE_RUNPATH__
88- if (*mylibname == '/')
89+ if (*mylibname == '/')
90 #endif
91- if ((tpnt = _dl_load_elf_shared_library(rflags, rpnt, mylibname)) != NULL)
92- return tpnt;
93- path_n = path+1;
94- }
95- path++;
96- } while (!done);
97+ if ((tpnt = _dl_load_elf_shared_library(rflags, rpnt, mylibname)) != NULL)
98+ return tpnt;
99+ }
100 return NULL;
101 }
102
103@@ -234,8 +238,10 @@
104 if (pnt) {
105 pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
106 _dl_if_debug_dprint("\tsearching RPATH='%s'\n", pnt);
107- if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
108+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt,
109+ tpnt->libname)) != NULL)
110 return tpnt1;
111+
112 }
113 #endif
114
115@@ -243,7 +249,7 @@
116 /* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
117 if (_dl_library_path) {
118 _dl_if_debug_dprint("\tsearching LD_LIBRARY_PATH='%s'\n", _dl_library_path);
119- if ((tpnt1 = search_for_named_library(libname, rflags, _dl_library_path, rpnt)) != NULL)
120+ if ((tpnt1 = search_for_named_library(libname, rflags, _dl_library_path, rpnt, NULL)) != NULL)
121 {
122 return tpnt1;
123 }
124@@ -257,7 +263,7 @@
125 if (pnt) {
126 pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
127 _dl_if_debug_dprint("\tsearching RUNPATH='%s'\n", pnt);
128- if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
129+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
130 return tpnt1;
131 }
132 #endif
133@@ -291,7 +297,7 @@
134 /* Look for libraries wherever the shared library loader
135 * was installed */
136 _dl_if_debug_dprint("\tsearching ldso dir='%s'\n", _dl_ldsopath);
137- tpnt1 = search_for_named_library(libname, rflags, _dl_ldsopath, rpnt);
138+ tpnt1 = search_for_named_library(libname, rflags, _dl_ldsopath, rpnt, NULL);
139 if (tpnt1 != NULL)
140 return tpnt1;
141 #endif
142@@ -304,7 +310,7 @@
143 #ifndef __LDSO_CACHE_SUPPORT__
144 ":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
145 #endif
146- , rpnt);
147+ , rpnt, NULL);
148 if (tpnt1 != NULL)
149 return tpnt1;
150
151Index: git/ldso/ldso/ldso.c
152===================================================================
153--- git.orig/ldso/ldso/ldso.c 2012-06-19 18:29:08.633931663 -0700
154+++ git/ldso/ldso/ldso.c 2012-06-19 18:29:10.197931738 -0700
155@@ -403,6 +403,20 @@
156 return p - list;
157 }
158
159+static void _dl_setup_progname(const char *argv0)
160+{
161+ char image[PATH_MAX];
162+ ssize_t s;
163+
164+ s = _dl_readlink("/proc/self/exe", image, sizeof(image));
165+ if (s > 0 && image[0] == '/') {
166+ image[s] = 0;
167+ _dl_progname = _dl_strdup(image);
168+ } else if (argv0) {
169+ _dl_progname = argv0;
170+ }
171+}
172+
173 void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
174 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
175 DL_GET_READY_TO_RUN_EXTRA_PARMS)
176@@ -454,9 +468,7 @@
177 * been fixed up by now. Still no function calls outside of this
178 * library, since the dynamic resolver is not yet ready.
179 */
180- if (argv[0]) {
181- _dl_progname = argv[0];
182- }
183+ _dl_setup_progname(argv[0]);
184
185 #ifdef __DSBT__
186 _dl_ldso_dsbt = (void *)tpnt->dynamic_info[DT_DSBT_BASE_IDX];