[wasm] dln.c: Guard dladdr use in symbol incompatibility check

wasi-libc recently added a family of `dl*` functions[^1], but it still
doesn't have `dladdr` unlike other platforms. Guard the use of `dladdr`
with `HAVE_DLADDR` to avoid build failure with the head version of
wasi-libc.
The library name is used only for diagnostic purpose if it's not NULL,
so it's safe to skip it.

[^1]: b85d65528d
This commit is contained in:
Yuta Saito 2023-12-17 14:21:17 +00:00
parent acfd2e9d64
commit 36b389c206

4
dln.c
View File

@ -272,13 +272,15 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine)
static bool
dln_incompatible_func(void *handle, const char *funcname, void *const fp, const char **libname)
{
Dl_info dli;
void *ex = dlsym(handle, funcname);
if (!ex) return false;
if (ex == fp) return false;
# if defined(HAVE_DLADDR)
Dl_info dli;
if (dladdr(ex, &dli)) {
*libname = dli.dli_fname;
}
# endif
return true;
}