fix regression in dlopen promotion from RTLD_LOCAL to RTLD_GLOBAL

commit 4ff234f6cb inadvertently removed
the logic to do this when changing the representation of global
status.
This commit is contained in:
Rich Felker 2017-07-04 11:34:39 -04:00
parent 66b53cfa88
commit 43c423af5b
1 changed files with 6 additions and 1 deletions

View File

@ -1771,7 +1771,8 @@ void *dlopen(const char *file, int mode)
} }
/* First load handling */ /* First load handling */
if (!p->deps) { int first_load = !p->deps;
if (first_load) {
load_deps(p); load_deps(p);
if (!p->relocated && (mode & RTLD_LAZY)) { if (!p->relocated && (mode & RTLD_LAZY)) {
prepare_lazy(p); prepare_lazy(p);
@ -1779,11 +1780,15 @@ void *dlopen(const char *file, int mode)
if (!p->deps[i]->relocated) if (!p->deps[i]->relocated)
prepare_lazy(p->deps[i]); prepare_lazy(p->deps[i]);
} }
}
if (first_load || (mode & RTLD_GLOBAL)) {
/* Make new symbols global, at least temporarily, so we can do /* Make new symbols global, at least temporarily, so we can do
* relocations. If not RTLD_GLOBAL, this is reverted below. */ * relocations. If not RTLD_GLOBAL, this is reverted below. */
add_syms(p); add_syms(p);
for (i=0; p->deps[i]; i++) for (i=0; p->deps[i]; i++)
add_syms(p->deps[i]); add_syms(p->deps[i]);
}
if (first_load) {
reloc_all(p); reloc_all(p);
} }