lift single lib statement restriction
[m6w6/ext-psi] / src / types / decl_extvar.c
index d85258b1726c9344d565be112217f7c3c770cbf7..e49804c105b31b80ca21ea72591134e382d34ce8 100644 (file)
@@ -70,6 +70,14 @@ bool psi_decl_extvar_validate(struct psi_data *data,
                return false;
        }
 
+       if (!evar->sym) {
+               size_t i = 0;
+               void *dl;
+
+               while (!evar->sym && psi_plist_get(data->file.dlopened, i++, &dl)) {
+                       evar->sym = dlsym(dl, evar->arg->var->name);
+               }
+       }
        if (!evar->sym) {
 #ifndef RTLD_NEXT
 # define RTLD_NEXT ((void *) -1l)
@@ -77,7 +85,7 @@ bool psi_decl_extvar_validate(struct psi_data *data,
 #ifndef RTLD_DEFAULT
 # define RTLD_DEFAULT ((void *) 0)
 #endif
-               evar->sym = dlsym(scope->dlopened ?: RTLD_DEFAULT, evar->arg->var->name);
+               evar->sym = dlsym(RTLD_DEFAULT, evar->arg->var->name);
                if (!evar->sym) {
                        data->error(data, evar->arg->var->token, PSI_WARNING,
                                        "Failed to locate symbol '%s': %s", evar->arg->var->name,