summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/uclibc
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2011-06-21 16:01:15 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-22 16:57:34 +0100
commit7c8e4f1cea69ab933da3d35279c2fffc5f78113e (patch)
treed83cadbbcfe63babc3f6e4eb4298254c4396621a /meta/recipes-core/uclibc
parent42e60945989da41b18e9fc2b6270cbb441dd9cd4 (diff)
downloadpoky-7c8e4f1cea69ab933da3d35279c2fffc5f78113e.tar.gz
uclibc: Add support for $ORIGIN
This is required by systemd (From OE-Core rev: 08ad271248cc2c7cd9cfbe683d2335337f5ebb8b) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/uclibc')
-rw-r--r--meta/recipes-core/uclibc/uclibc-git/orign_path.patch183
-rw-r--r--meta/recipes-core/uclibc/uclibc-git/rtld_no.patch215
-rw-r--r--meta/recipes-core/uclibc/uclibc_git.bb4
3 files changed, 401 insertions, 1 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 0000000000..631951e489
--- /dev/null
+++ b/meta/recipes-core/uclibc/uclibc-git/orign_path.patch
@@ -0,0 +1,183 @@
1Patch is backported from
2http://lists.busybox.net/pipermail/uclibc/2011-March/045003.html
3
4Upstream-Status: Pending
5
6diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
7index 505247e..2b2d429 100644
8--- a/ldso/ldso/dl-elf.c
9+++ b/ldso/ldso/dl-elf.c
10@@ -133,53 +133,60 @@ _dl_protect_relro (struct elf_resolve *l)
11 * in uClibc/ldso/util/ldd.c */
12 static struct elf_resolve *
13 search_for_named_library(const char *name, int secure, 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+ const char *p, *pn;
20 struct elf_resolve *tpnt;
21- int done;
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- }
51- if (*path == ':') {
52- *path = 0;
53- if (*path_n)
54- _dl_strcpy(mylibname, path_n);
55- else
56- _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */
57- _dl_strcat(mylibname, "/");
58- _dl_strcat(mylibname, name);
59- if ((tpnt = _dl_load_elf_shared_library(secure, rpnt, mylibname)) != NULL)
60- return tpnt;
61- path_n = path+1;
62+ for (p = path_list; p != NULL; p = pn) {
63+ pn = _dl_strchr(p + 1, ':');
64+ if (pn != NULL) {
65+ plen = pn - p;
66+ pn++;
67+ } else
68+ plen = _dl_strlen(p);
69+
70+ if (plen >= 7 && _dl_memcmp(p, "$ORIGIN", 7) == 0) {
71+ int olen;
72+ if (secure && plen != 7)
73+ continue;
74+ if (origin == NULL)
75+ continue;
76+ for (olen = _dl_strlen(origin) - 1; olen >= 0 && origin[olen] != '/'; olen--)
77+ ;
78+ if (olen <= 0)
79+ continue;
80+ _dl_memcpy(&mylibname[0], origin, olen);
81+ _dl_memcpy(&mylibname[olen], p + 7, plen - 7);
82+ mylibname[olen + plen - 7] = 0;
83+ } else if (plen != 0) {
84+ _dl_memcpy(mylibname, p, plen);
85+ mylibname[plen] = 0;
86+ } else {
87+ _dl_strcpy(mylibname, ".");
88 }
89- path++;
90- } while (!done);
91+ _dl_strcat(mylibname, "/");
92+ _dl_strcat(mylibname, name);
93+
94+ tpnt = _dl_load_elf_shared_library(secure, rpnt, mylibname);
95+ if (tpnt != NULL)
96+ return tpnt;
97+ }
98+
99 return NULL;
100 }
101
102@@ -231,7 +238,8 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
103 if (pnt) {
104 pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
105 _dl_if_debug_dprint("\tsearching RPATH='%s'\n", pnt);
106- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
107+ if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt,
108+ tpnt->libname)) != NULL)
109 return tpnt1;
110 }
111 #endif
112@@ -239,7 +247,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
113 /* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
114 if (_dl_library_path) {
115 _dl_if_debug_dprint("\tsearching LD_LIBRARY_PATH='%s'\n", _dl_library_path);
116- if ((tpnt1 = search_for_named_library(libname, secure, _dl_library_path, rpnt)) != NULL)
117+ if ((tpnt1 = search_for_named_library(libname, secure, _dl_library_path, rpnt, NULL)) != NULL)
118 {
119 return tpnt1;
120 }
121@@ -253,7 +261,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
122 if (pnt) {
123 pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
124 _dl_if_debug_dprint("\tsearching RUNPATH='%s'\n", pnt);
125- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
126+ if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt, NULL)) != NULL)
127 return tpnt1;
128 }
129 #endif
130@@ -287,7 +295,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
131 /* Look for libraries wherever the shared library loader
132 * was installed */
133 _dl_if_debug_dprint("\tsearching ldso dir='%s'\n", _dl_ldsopath);
134- tpnt1 = search_for_named_library(libname, secure, _dl_ldsopath, rpnt);
135+ tpnt1 = search_for_named_library(libname, secure, _dl_ldsopath, rpnt, NULL);
136 if (tpnt1 != NULL)
137 return tpnt1;
138
139@@ -300,7 +308,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
140 #ifndef __LDSO_CACHE_SUPPORT__
141 ":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
142 #endif
143- , rpnt);
144+ , rpnt, NULL);
145 if (tpnt1 != NULL)
146 return tpnt1;
147
148diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
149index 7ee9257..9423670 100644
150--- a/ldso/ldso/ldso.c
151+++ b/ldso/ldso/ldso.c
152@@ -272,6 +272,20 @@ static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
153 }
154 }
155
156+static void _dl_setup_progname(const char *argv0)
157+{
158+ char image[PATH_MAX];
159+ ssize_t s;
160+
161+ s = _dl_readlink("/proc/self/exe", image, sizeof(image));
162+ if (s > 0 && image[0] == '/') {
163+ image[s] = 0;
164+ _dl_progname = _dl_strdup(image);
165+ } else if (argv0) {
166+ _dl_progname = argv0;
167+ }
168+}
169+
170 void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
171 ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp,
172 char **argv
173@@ -321,9 +335,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
174 * been fixed up by now. Still no function calls outside of this
175 * library, since the dynamic resolver is not yet ready.
176 */
177- if (argv[0]) {
178- _dl_progname = argv[0];
179- }
180+ _dl_setup_progname(argv[0]);
181
182 if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) {
183 _dl_dprintf(_dl_debug_file, "Standalone execution is not supported yet\n");
diff --git a/meta/recipes-core/uclibc/uclibc-git/rtld_no.patch b/meta/recipes-core/uclibc/uclibc-git/rtld_no.patch
new file mode 100644
index 0000000000..30cb7f6ef6
--- /dev/null
+++ b/meta/recipes-core/uclibc/uclibc-git/rtld_no.patch
@@ -0,0 +1,215 @@
1Patch is backported from
2http://lists.busybox.net/pipermail/uclibc/2011-March/045004.html
3
4Upstream-Status: Pending
5
6diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
7index 7fbb373..7102351 100644
8--- a/ldso/include/dl-elf.h
9+++ b/ldso/include/dl-elf.h
10@@ -25,16 +25,18 @@ static __inline__ void _dl_map_cache(void) { }
11 static __inline__ void _dl_unmap_cache(void) { }
12 #endif
13
14+#define DL_RESOLVE_SECURE 0x0001
15+#define DL_RESOLVE_NOLOAD 0x0002
16
17 /* Function prototypes for non-static stuff in readelflib1.c */
18 extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
19 unsigned long rel_addr, unsigned long rel_size);
20 extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
21 unsigned long rel_addr, unsigned long rel_size);
22-extern struct elf_resolve * _dl_load_shared_library(int secure,
23+extern struct elf_resolve * _dl_load_shared_library(int resolve_flags,
24 struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
25 int trace_loaded_objects);
26-extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
27+extern struct elf_resolve * _dl_load_elf_shared_library(int resolve_flags,
28 struct dyn_elf **rpnt, char *libname);
29 extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
30 int trace_loaded_objects);
31diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
32index 2b2d429..6d35bf2 100644
33--- a/ldso/ldso/dl-elf.c
34+++ b/ldso/ldso/dl-elf.c
35@@ -132,7 +132,7 @@ _dl_protect_relro (struct elf_resolve *l)
36 /* This function's behavior must exactly match that
37 * in uClibc/ldso/util/ldd.c */
38 static struct elf_resolve *
39-search_for_named_library(const char *name, int secure, const char *path_list,
40+search_for_named_library(const char *name, int resolve_flags, const char *path_list,
41 struct dyn_elf **rpnt, const char *origin)
42 {
43 char *mylibname;
44@@ -162,7 +162,7 @@ search_for_named_library(const char *name, int secure, const char *path_list,
45
46 if (plen >= 7 && _dl_memcmp(p, "$ORIGIN", 7) == 0) {
47 int olen;
48- if (secure && plen != 7)
49+ if ((resolve_flags & DL_RESOLVE_SECURE) && plen != 7)
50 continue;
51 if (origin == NULL)
52 continue;
53@@ -182,7 +182,7 @@ search_for_named_library(const char *name, int secure, const char *path_list,
54 _dl_strcat(mylibname, "/");
55 _dl_strcat(mylibname, name);
56
57- tpnt = _dl_load_elf_shared_library(secure, rpnt, mylibname);
58+ tpnt = _dl_load_elf_shared_library(resolve_flags, rpnt, mylibname);
59 if (tpnt != NULL)
60 return tpnt;
61 }
62@@ -194,7 +194,7 @@ search_for_named_library(const char *name, int secure, const char *path_list,
63 unsigned long _dl_error_number;
64 unsigned long _dl_internal_error_number;
65
66-struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
67+struct elf_resolve *_dl_load_shared_library(int resolve_flags, struct dyn_elf **rpnt,
68 struct elf_resolve *tpnt, char *full_libname, int attribute_unused trace_loaded_objects)
69 {
70 char *pnt;
71@@ -223,7 +223,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
72
73 if (libname != full_libname) {
74 _dl_if_debug_dprint("\ttrying file='%s'\n", full_libname);
75- tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname);
76+ tpnt1 = _dl_load_elf_shared_library(resolve_flags, rpnt, full_libname);
77 if (tpnt1) {
78 return tpnt1;
79 }
80@@ -238,7 +238,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
81 if (pnt) {
82 pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
83 _dl_if_debug_dprint("\tsearching RPATH='%s'\n", pnt);
84- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt,
85+ if ((tpnt1 = search_for_named_library(libname, resolve_flags, pnt, rpnt,
86 tpnt->libname)) != NULL)
87 return tpnt1;
88 }
89@@ -247,7 +247,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
90 /* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
91 if (_dl_library_path) {
92 _dl_if_debug_dprint("\tsearching LD_LIBRARY_PATH='%s'\n", _dl_library_path);
93- if ((tpnt1 = search_for_named_library(libname, secure, _dl_library_path, rpnt, NULL)) != NULL)
94+ if ((tpnt1 = search_for_named_library(libname, resolve_flags, _dl_library_path, rpnt, NULL)) != NULL)
95 {
96 return tpnt1;
97 }
98@@ -261,7 +261,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
99 if (pnt) {
100 pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
101 _dl_if_debug_dprint("\tsearching RUNPATH='%s'\n", pnt);
102- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt, NULL)) != NULL)
103+ if ((tpnt1 = search_for_named_library(libname, resolve_flags, pnt, rpnt, NULL)) != NULL)
104 return tpnt1;
105 }
106 #endif
107@@ -284,7 +284,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
108 || libent[i].flags == LIB_ELF_LIBC0
109 || libent[i].flags == LIB_ELF_LIBC5)
110 && _dl_strcmp(libname, strs + libent[i].sooffset) == 0
111- && (tpnt1 = _dl_load_elf_shared_library(secure, rpnt, strs + libent[i].liboffset))
112+ && (tpnt1 = _dl_load_elf_shared_library(resolve_flags, rpnt, strs + libent[i].liboffset))
113 ) {
114 return tpnt1;
115 }
116@@ -295,14 +295,14 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
117 /* Look for libraries wherever the shared library loader
118 * was installed */
119 _dl_if_debug_dprint("\tsearching ldso dir='%s'\n", _dl_ldsopath);
120- tpnt1 = search_for_named_library(libname, secure, _dl_ldsopath, rpnt, NULL);
121+ tpnt1 = search_for_named_library(libname, resolve_flags, _dl_ldsopath, rpnt, NULL);
122 if (tpnt1 != NULL)
123 return tpnt1;
124
125 /* Lastly, search the standard list of paths for the library.
126 This list must exactly match the list in uClibc/ldso/util/ldd.c */
127 _dl_if_debug_dprint("\tsearching full lib path list\n");
128- tpnt1 = search_for_named_library(libname, secure,
129+ tpnt1 = search_for_named_library(libname, resolve_flags,
130 UCLIBC_RUNTIME_PREFIX "lib:"
131 UCLIBC_RUNTIME_PREFIX "usr/lib"
132 #ifndef __LDSO_CACHE_SUPPORT__
133@@ -329,7 +329,7 @@ goof:
134 * are required.
135 */
136
137-struct elf_resolve *_dl_load_elf_shared_library(int secure,
138+struct elf_resolve *_dl_load_elf_shared_library(int resolve_flags,
139 struct dyn_elf **rpnt, char *libname)
140 {
141 ElfW(Ehdr) *epnt;
142@@ -368,7 +368,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
143 }
144 /* If we are in secure mode (i.e. a setu/gid binary using LD_PRELOAD),
145 we don't load the library if it isn't setuid. */
146- if (secure) {
147+ if (resolve_flags & DL_RESOLVE_SECURE) {
148 if (!(st.st_mode & S_ISUID)) {
149 _dl_close(infile);
150 return NULL;
151@@ -384,6 +384,10 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
152 return tpnt;
153 }
154 }
155+ if (resolve_flags & DL_RESOLVE_NOLOAD) {
156+ _dl_close(infile);
157+ return NULL;
158+ }
159 header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
160 MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZE, -1, 0);
161 if (_dl_mmap_check_error(header)) {
162diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
163index 9423670..b71af34 100644
164--- a/ldso/ldso/ldso.c
165+++ b/ldso/ldso/ldso.c
166@@ -646,7 +646,9 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
167 if (!_dl_secure || _dl_strchr(str, '/') == NULL) {
168 _dl_if_debug_dprint("\tfile='%s'; needed by '%s'\n", str, _dl_progname);
169
170- tpnt1 = _dl_load_shared_library(_dl_secure, &rpnt, NULL, str, trace_loaded_objects);
171+ tpnt1 = _dl_load_shared_library(
172+ _dl_secure ? DL_RESOLVE_SECURE : 0,
173+ &rpnt, NULL, str, trace_loaded_objects);
174 if (!tpnt1) {
175 #ifdef __LDSO_LDD_SUPPORT__
176 if (trace_loaded_objects)
177diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
178index 68cd579..edf38d2 100644
179--- a/ldso/libdl/libdl.c
180+++ b/ldso/libdl/libdl.c
181@@ -288,7 +288,7 @@ void *dlopen(const char *libname, int flag)
182 #endif
183
184 /* A bit of sanity checking... */
185- if (!(flag & (RTLD_LAZY|RTLD_NOW))) {
186+ if (!(flag & (RTLD_LAZY|RTLD_NOW|RTLD_NOLOAD))) {
187 _dl_error_number = LD_BAD_HANDLE;
188 return NULL;
189 }
190@@ -358,8 +358,9 @@ void *dlopen(const char *libname, int flag)
191 /* Try to load the specified library */
192 _dl_if_debug_print("Trying to dlopen '%s', RTLD_GLOBAL:%d RTLD_NOW:%d\n",
193 (char*)libname, (flag & RTLD_GLOBAL ? 1:0), (now_flag & RTLD_NOW ? 1:0));
194- tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
195
196+ tpnt = _dl_load_shared_library((flag & RTLD_NOLOAD) ? DL_RESOLVE_NOLOAD : 0,
197+ &rpnt, tfrom, (char*)libname, 0);
198 if (tpnt == NULL) {
199 _dl_unmap_cache();
200 return NULL;
201diff --git a/libc/sysdeps/linux/common/bits/dlfcn.h b/libc/sysdeps/linux/common/bits/dlfcn.h
202index 4bfbbff..47b42ad 100644
203--- a/libc/sysdeps/linux/common/bits/dlfcn.h
204+++ b/libc/sysdeps/linux/common/bits/dlfcn.h
205@@ -24,9 +24,9 @@
206 /* The MODE argument to `dlopen' contains one of the following: */
207 #define RTLD_LAZY 0x00001 /* Lazy function call binding. */
208 #define RTLD_NOW 0x00002 /* Immediate function call binding. */
209-#if 0 /* uClibc doesnt support these */
210-#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
211+#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
212 #define RTLD_NOLOAD 0x00004 /* Do not load the object. */
213+#if 0 /* uClibc doesnt support these */
214 #define RTLD_DEEPBIND 0x00008 /* Use deep binding. */
215 #endif
diff --git a/meta/recipes-core/uclibc/uclibc_git.bb b/meta/recipes-core/uclibc/uclibc_git.bb
index b8f58f0095..6445243782 100644
--- a/meta/recipes-core/uclibc/uclibc_git.bb
+++ b/meta/recipes-core/uclibc/uclibc_git.bb
@@ -2,7 +2,7 @@ SRCREV="71d63ed75648da9b0b71afabb9c60aaad792c55c"
2 2
3require uclibc.inc 3require uclibc.inc
4PV = "0.9.31+0.9.32rc3" 4PV = "0.9.31+0.9.32rc3"
5PR = "${INC_PR}.3" 5PR = "${INC_PR}.4"
6PROVIDES += "virtual/${TARGET_PREFIX}libc-for-gcc" 6PROVIDES += "virtual/${TARGET_PREFIX}libc-for-gcc"
7 7
8FILESPATH = "${@base_set_filespath([ '${FILE_DIRNAME}/uclibc-git' ], d)}" 8FILESPATH = "${@base_set_filespath([ '${FILE_DIRNAME}/uclibc-git' ], d)}"
@@ -27,5 +27,7 @@ SRC_URI = "git://uclibc.org/uClibc.git;branch=master;protocol=git \
27 file://append_UCLIBC_EXTRA_CFLAGS.patch \ 27 file://append_UCLIBC_EXTRA_CFLAGS.patch \
28 file://compile-arm-fork-with-O2.patch \ 28 file://compile-arm-fork-with-O2.patch \
29 file://epoll-asm-fix.patch \ 29 file://epoll-asm-fix.patch \
30 file://orign_path.patch \
31 file://rtld_no.patch \
30 " 32 "
31S = "${WORKDIR}/git" 33S = "${WORKDIR}/git"