From e8bff295f98ac36ef8b545515a90ce34cbb8a17f Mon Sep 17 00:00:00 2001 From: Christian Jullien Date: Sun, 21 Feb 2021 08:38:39 +0100 Subject: [PATCH] [macOS]: arm64, very early stage of Big Sur M1 native port. --- Makefile | 2 ++ tccrun.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 06899d1e..6d09b653 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,7 @@ DEF-arm = $(DEF-arm-eabihf) DEF-arm-NetBSD = $(DEF-arm-eabihf) -DTARGETOS_NetBSD DEF-arm-wince = $(DEF-arm-eabihf) -DTCC_TARGET_PE DEF-arm64 = -DTCC_TARGET_ARM64 +DEF-arm64-osx = $(DEF-arm64) -DTCC_TARGET_MACHO DEF-arm64-FreeBSD = $(DEF-arm64) -DTARGETOS_FreeBSD DEF-arm64-NetBSD = $(DEF-arm64) -DTARGETOS_NetBSD DEF-arm64-OpenBSD = $(DEF-arm64) -DTARGETOS_OpenBSD @@ -198,6 +199,7 @@ arm-vfp_FILES = $(arm_FILES) arm-eabi_FILES = $(arm_FILES) arm-eabihf_FILES = $(arm_FILES) arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c arm64-asm.c +arm64-osx_FILES = $(arm64_FILES) tccmacho.c c67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c riscv64_FILES = $(CORE_FILES) riscv64-gen.c riscv64-link.c riscv64-asm.c diff --git a/tccrun.c b/tccrun.c index ffb3c685..792e6be2 100644 --- a/tccrun.c +++ b/tccrun.c @@ -716,6 +716,11 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc) #elif defined(__arm__) rc->ip = uc->uc_mcontext.arm_pc; rc->fp = uc->uc_mcontext.arm_fp; +#elif defined(__aarch64__) && defined(__APPLE__) + // see: + // /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/mach/arm/_structs.h + rc->ip = uc->uc_mcontext->__ss.__pc; + rc->fp = uc->uc_mcontext->__ss.__fp; #elif defined(__aarch64__) && defined(__FreeBSD__) rc->ip = uc->uc_mcontext.mc_gpregs.gp_elr; /* aka REG_PC */ rc->fp = uc->uc_mcontext.mc_gpregs.gp_x[29];