blob: 266594fd1fd65628a7069ca53338e7aacdf4c0a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* This file is used to build libdl.so with stub versions of `dlopen`, `dlsym`,
* etc. The intention is that this stubbed libdl.so can be used to build
* libraries and applications which use `dlopen` without committing to a
* specific runtime implementation. Later, it can be replaced with a real,
* working libdl.so (e.g. at runtime or component composition time).
*
* For example, the `wasm-tools component link` subcommand can be used to create
* a component that bundles any `dlopen`-able libraries in such a way that their
* function exports can be resolved symbolically at runtime using an
* implementation of libdl.so designed for that purpose. In other cases, a
* runtime might provide Emscripten-style dynamic linking via URLs or else a
* more traditional, filesystem-based implementation. Finally, even this
* stubbed version of libdl.so can be used at runtime in cases where dynamic
* library resolution cannot or should not be supported (and the application can
* handle this situation gracefully). */
#include <stddef.h>
#include <dlfcn.h>
static const char *error = NULL;
weak int dlclose(void *library)
{
error = "dlclose not implemented";
return -1;
}
weak char *dlerror(void)
{
const char *var = error;
error = NULL;
return (char*) var;
}
weak void *dlopen(const char *name, int flags)
{
error = "dlopen not implemented";
return NULL;
}
weak void *dlsym(void *library, const char *name)
{
error = "dlsym not implemented";
return NULL;
}
|