about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-06-30 23:02:27 -0400
committerRich Felker <dalias@aerifal.cx>2011-06-30 23:02:27 -0400
commit191ebcac31ceb27664790a70a36ff4602e12d9d0 (patch)
tree958ef4eb5d1e61937e1d0644827a600fb33c88b0
parent17be8291048587a166a6707f394fe0d48b078ce9 (diff)
downloadmusl-191ebcac31ceb27664790a70a36ff4602e12d9d0.tar.gz
musl-191ebcac31ceb27664790a70a36ff4602e12d9d0.tar.xz
musl-191ebcac31ceb27664790a70a36ff4602e12d9d0.zip
simple rpath support (no token expansion yet) for dynamic linker
-rw-r--r--src/ldso/dynlink.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 465fe4cf..fc06685f 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -53,7 +53,7 @@ struct dso
 };
 
 static struct dso *head, *tail, *libc;
-static char *env_path, *sys_path;
+static char *env_path, *sys_path, *r_path;
 static int rtld_used;
 static int runtime;
 static jmp_buf rtld_fail;
@@ -316,7 +316,8 @@ static struct dso *load_library(const char *name)
 	} else {
 		if (strlen(name) > NAME_MAX) return 0;
 		fd = -1;
-		if (env_path) fd = path_open(name, env_path);
+		if (r_path) fd = path_open(name, r_path);
+		if (fd < 0 && env_path) fd = path_open(name, env_path);
 		if (fd < 0) {
 			if (!sys_path) {
 				FILE *f = fopen(ETC_LDSO_PATH, "r");
@@ -379,6 +380,10 @@ static void load_deps(struct dso *p)
 	struct dso ***deps = &p->deps, **tmp, *dep;
 	for (; p; p=p->next) {
 		for (i=0; p->dynv[i]; i+=2) {
+			if (p->dynv[i] != DT_RPATH) continue;
+			r_path = (void *)(p->strings + p->dynv[i+1]);
+		}
+		for (i=0; p->dynv[i]; i+=2) {
 			if (p->dynv[i] != DT_NEEDED) continue;
 			dep = load_library(p->strings + p->dynv[i+1]);
 			if (!dep) {
@@ -395,6 +400,7 @@ static void load_deps(struct dso *p)
 				*deps = tmp;
 			}
 		}
+		r_path = 0;
 	}
 }