2021-02-06 07:58:12 +00:00
|
|
|
MAIN_C = r"""
|
2020-12-22 03:25:07 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <dlfcn.h>
|
2021-02-06 07:58:12 +00:00
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
void never_called()
|
|
|
|
{
|
|
|
|
jmp_buf buf;
|
|
|
|
int i=setjmp(buf);
|
|
|
|
longjmp(buf,1);
|
|
|
|
}
|
|
|
|
|
2020-12-22 03:25:07 +00:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
puts("hello from main");
|
|
|
|
void *handle = dlopen("library.wasm", RTLD_NOW);
|
|
|
|
if (!handle) {
|
|
|
|
puts("cannot load side module");
|
|
|
|
puts(dlerror());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
typedef void (*type_v)();
|
|
|
|
type_v side_func = (type_v) dlsym(handle, "foo");
|
|
|
|
if (!side_func) {
|
|
|
|
puts("cannot load side function");
|
|
|
|
puts(dlerror());
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
side_func();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
"""
|