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