diff options
author | nsz <nsz@port70.net> | 2012-03-23 11:16:56 +0100 |
---|---|---|
committer | nsz <nsz@port70.net> | 2012-03-23 11:16:56 +0100 |
commit | c5ec5b2ce93bd87eb3dbf966d8bf279089f8a35d (patch) | |
tree | 35a276d479538eb3898e47358e9e8eded63cf5cc /src/ldso/dynlink.c | |
parent | 6d8df2b9720b7133a0735c9d5a2aae55021bb2c2 (diff) | |
parent | ad2d2b963a4bf9e2631b345c898e8715b36b459e (diff) | |
download | musl-c5ec5b2ce93bd87eb3dbf966d8bf279089f8a35d.tar.gz musl-c5ec5b2ce93bd87eb3dbf966d8bf279089f8a35d.tar.bz2 musl-c5ec5b2ce93bd87eb3dbf966d8bf279089f8a35d.tar.xz musl-c5ec5b2ce93bd87eb3dbf966d8bf279089f8a35d.zip |
Merge branch 'master' of git://git.etalabs.net/musl
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r-- | src/ldso/dynlink.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 6ff8850c..e0013ec0 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -1,4 +1,3 @@ -#ifdef __PIC__ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -18,6 +17,10 @@ #include <ctype.h> #include <dlfcn.h> +static int errflag; + +#ifdef __PIC__ + #include "reloc.h" #if ULONG_MAX == 0xffffffff @@ -631,12 +634,13 @@ void *dlopen(const char *file, int mode) tail = orig_tail; tail->next = 0; p = 0; + } else p = load_library(file); + + if (!p) { + errflag = 1; goto end; } - p = load_library(file); - if (!p) goto end; - /* First load handling */ if (!p->deps) { load_deps(p); @@ -674,8 +678,11 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra) if (!p) p=head; p=p->next; } - if (p == head || p == RTLD_DEFAULT) - return find_sym(head, s, 0); + if (p == head || p == RTLD_DEFAULT) { + void *res = find_sym(head, s, 0); + if (!res) errflag = 1; + return res; + } h = hash(s); sym = lookup(s, h, p->syms, p->hashtab, p->strings); if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES)) @@ -686,6 +693,7 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra) if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES)) return p->deps[i]->base + sym->st_value; } + errflag = 1; return 0; } @@ -710,6 +718,8 @@ void *__dlsym(void *p, const char *s, void *ra) char *dlerror() { + if (!errflag) return 0; + errflag = 0; return "unknown error"; } |