diff options
author | Rich Felker <dalias@aerifal.cx> | 2017-03-21 08:35:59 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2017-03-21 08:39:37 -0400 |
commit | 0c53178ec09478ca5f6ca6b5ad09d50a10c8f19d (patch) | |
tree | 679a71aa1d0dd4ac7f387d4ff32ed2df9bc3360c /ldso/dynlink.c | |
parent | dbff2bb889bc831599b022c49252c69bf48f4e4e (diff) | |
download | musl-0c53178ec09478ca5f6ca6b5ad09d50a10c8f19d.tar.gz musl-0c53178ec09478ca5f6ca6b5ad09d50a10c8f19d.tar.bz2 musl-0c53178ec09478ca5f6ca6b5ad09d50a10c8f19d.tar.xz musl-0c53178ec09478ca5f6ca6b5ad09d50a10c8f19d.zip |
fix dlopen/dlsym regression opening libs already loaded at startup
commit 4ff234f6cba96403b5de6d29d48a59fd73252040 erroneously changed
the condition for running certain code at dlopen time to check whether
the library was already relocated rather than whether it already had
its deps[] table filled. this was out of concern over whether the code
under the conditional would be idempotent/safe to call on an
already-loaded libraries. however, I missed a consideration in the
opposite direction: if a library was loaded at program startup rather
than dlopen, its deps[] table was not yet allocated/filled, and
load_deps needs to be called at dlopen time in order for dlsym to be
able to perform dependency-order symbol lookups.
in order to avoid wasteful allocation of lazy-binding relocation
tables for libraries which were already loaded and relocated at
startup, the check for !p->relocated is not deleted entirely, but
moved to apply only to allocation of these dables.
Diffstat (limited to 'ldso/dynlink.c')
-rw-r--r-- | ldso/dynlink.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ldso/dynlink.c b/ldso/dynlink.c index 5361b844..d20dbd87 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -1768,9 +1768,9 @@ void *dlopen(const char *file, int mode) } /* First load handling */ - if (!p->relocated) { + if (!p->deps) { load_deps(p); - if ((mode & RTLD_LAZY)) { + if (!p->relocated && (mode & RTLD_LAZY)) { prepare_lazy(p); if (p->deps) for (i=0; p->deps[i]; i++) if (!p->deps[i]->relocated) |