X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Ftypes%2Fdecl.c;fp=src%2Ftypes%2Fdecl.c;h=300f5bdd36b6e1a782285e54423dbfbb3e2064bf;hp=85d93d40cd63243cb93c6e3a15c240f27a8b314c;hb=02e801eabbe26a129ea05e6723c94e10bb653dab;hpb=b282753558305fe44bd0d268833e131e5ccf82e8 diff --git a/src/types/decl.c b/src/types/decl.c index 85d93d4..300f5bd 100644 --- a/src/types/decl.c +++ b/src/types/decl.c @@ -93,7 +93,7 @@ void psi_decl_dump(int fd, struct psi_decl *decl) } static inline bool psi_decl_validate_func(struct psi_data *data, - struct psi_decl *decl, struct psi_decl_arg *func, void *dl) + struct psi_decl *decl, struct psi_decl_arg *func) { struct psi_func_redir *redir; @@ -107,6 +107,14 @@ static inline bool psi_decl_validate_func(struct psi_data *data, decl->sym = redir->func; } } + if (!decl->sym) { + size_t i = 0; + void *dl; + + while (!decl->sym && psi_plist_get(data->file.dlopened, i++, &dl)) { + decl->sym = dlsym(dl, decl->redir ?: func->var->name); + } + } if (!decl->sym) { #ifndef RTLD_NEXT # define RTLD_NEXT ((void *) -1l) @@ -114,7 +122,7 @@ static inline bool psi_decl_validate_func(struct psi_data *data, #ifndef RTLD_DEFAULT # define RTLD_DEFAULT ((void *) 0) #endif - decl->sym = dlsym(dl ?: RTLD_DEFAULT, decl->redir ?: func->var->name); + decl->sym = dlsym(RTLD_DEFAULT, decl->redir ?: func->var->name); if (!decl->sym) { data->error(data, func->token, PSI_WARNING, "Failed to locate symbol '%s(%s)': %s", @@ -132,7 +140,7 @@ bool psi_decl_validate(struct psi_data *data, struct psi_decl *decl, if (!psi_decl_validate_nodl(data, decl, scope)) { return false; } - if (!psi_decl_validate_func(data, decl, decl->func, scope->dlopened)) { + if (!psi_decl_validate_func(data, decl, decl->func)) { return false; }