From a04dc12d72a76a08ba58c008e7200428453a40ff Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 6 Dec 2020 13:50:50 +0000 Subject: [PATCH] aarch64: add freestanding port --- README.md | 2 +- arch/aarch64/freestanding/bits.h | 34 ++++++++++++++++++++++++++++++++ arch/aarch64/makecontext.c | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 arch/aarch64/freestanding/bits.h diff --git a/README.md b/README.md index 832f5e4..1512b03 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Adding support for new architectures is easy, but you need to know assembly lang | Architecture | Works on musl | Syscall | Supports FREESTANDING | |--------------|---------------|---------|-----------------------| -| aarch64 | ✓ | | | +| aarch64 | ✓ | | ✓ | | arm | ✓ | | ✓ | | m68k | ✓ | | ✓ | | mips | ✓ | | ✓ | diff --git a/arch/aarch64/freestanding/bits.h b/arch/aarch64/freestanding/bits.h new file mode 100644 index 0000000..3d6e8d7 --- /dev/null +++ b/arch/aarch64/freestanding/bits.h @@ -0,0 +1,34 @@ +#ifndef LIBUCONTEXT_BITS_H +#define LIBUCONTEXT_BITS_H + +typedef unsigned long libucontext_greg_t; +typedef unsigned long libucontext_gregset_t[34]; + +typedef struct { + __uint128_t vregs[32]; + unsigned int fpsr; + unsigned int fpcr; +} libucontext_fpregset_t; + +typedef struct sigcontext { + unsigned long fault_address; + unsigned long regs[31]; + unsigned long sp, pc, pstate; + long double __reserved[256]; +} libucontext_mcontext_t; + +typedef struct { + void *ss_sp; + int ss_flags; + size_t ss_size; +} libucontext_stack_t; + +typedef struct libucontext_ucontext { + unsigned long uc_flags; + struct libucontext_ucontext *uc_link; + libucontext_stack_t uc_stack; + unsigned char __pad[128]; + libucontext_mcontext_t uc_mcontext; +} libucontext_ucontext_t; + +#endif diff --git a/arch/aarch64/makecontext.c b/arch/aarch64/makecontext.c index d2e90f5..fb291c5 100644 --- a/arch/aarch64/makecontext.c +++ b/arch/aarch64/makecontext.c @@ -23,7 +23,7 @@ extern void libucontext_trampoline(void); void -libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) +libucontext_makecontext(libucontext_ucontext_t *ucp, void (*func)(void), int argc, ...) { unsigned long *sp; unsigned long *regp;