Files
wasmtime/crates/runtime/src/helpers.c
Chris Fallin bab0c79c31 ARM64 backend, part 9 / 11: wasmtime support.
This commit adds a few odds and ends required to build wasmtime on ARM64
with the new backend. In particular, it adds:

- Support for the `Arm64Call` relocation type.
- Support for fetching the trap PC when a signal is received.
- A hook for `SIGTRAP`, which is sent by the `brk` opcode (in contrast to
  x86's `SIGILL`).

With the patch sequence up to and including this patch applied,
`wasmtime` can now compile and successfully execute code on arm64. Not
all tests pass yet, but basic Wasm/WASI tests work correctly.
2020-04-11 17:52:44 -07:00

38 lines
649 B
C

#include <setjmp.h>
int RegisterSetjmp(
void **buf_storage,
void (*body)(void*),
void *payload) {
jmp_buf buf;
if (setjmp(buf) != 0) {
return 0;
}
*buf_storage = &buf;
body(payload);
return 1;
}
void Unwind(void *JmpBuf) {
jmp_buf *buf = (jmp_buf*) JmpBuf;
longjmp(*buf, 1);
}
#ifdef __APPLE__
#include <sys/ucontext.h>
void* GetPcFromUContext(ucontext_t *cx) {
return (void*) cx->uc_mcontext->__ss.__rip;
}
#endif
#if defined(__linux__) && defined(__aarch64__)
#include <sys/ucontext.h>
void* GetPcFromUContext(ucontext_t *cx) {
return (void*) cx->uc_mcontext.pc;
}
#endif // __linux__ && __aarch64__