[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:
parent
acfd2e9d64
commit
36b389c206
4
dln.c
4
dln.c
@ -272,13 +272,15 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine)
|
|||||||
static bool
|
static bool
|
||||||
dln_incompatible_func(void *handle, const char *funcname, void *const fp, const char **libname)
|
dln_incompatible_func(void *handle, const char *funcname, void *const fp, const char **libname)
|
||||||
{
|
{
|
||||||
Dl_info dli;
|
|
||||||
void *ex = dlsym(handle, funcname);
|
void *ex = dlsym(handle, funcname);
|
||||||
if (!ex) return false;
|
if (!ex) return false;
|
||||||
if (ex == fp) return false;
|
if (ex == fp) return false;
|
||||||
|
# if defined(HAVE_DLADDR)
|
||||||
|
Dl_info dli;
|
||||||
if (dladdr(ex, &dli)) {
|
if (dladdr(ex, &dli)) {
|
||||||
*libname = dli.dli_fname;
|
*libname = dli.dli_fname;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user