From 163c11d989881f4cb86f58588f695cb0aee5aecc Mon Sep 17 00:00:00 2001 From: osy <50960678+osy@users.noreply.github.com> Date: Sat, 2 Jan 2021 18:34:13 -0800 Subject: [PATCH] build: support mach-o ABI --- arch/aarch64/swapcontext.S | 2 +- arch/common/common-defs.h | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/arch/aarch64/swapcontext.S b/arch/aarch64/swapcontext.S index 19303a7..d5bad2c 100644 --- a/arch/aarch64/swapcontext.S +++ b/arch/aarch64/swapcontext.S @@ -51,7 +51,7 @@ FUNC(libucontext_swapcontext) /* move x1 to x0 and call setcontext */ mov x0, x1 - bl libucontext_setcontext + bl PROC_NAME(libucontext_setcontext) /* hmm, we came back here try to return */ mov x30, x28 diff --git a/arch/common/common-defs.h b/arch/common/common-defs.h index 8a5f12d..3e8b607 100644 --- a/arch/common/common-defs.h +++ b/arch/common/common-defs.h @@ -18,15 +18,27 @@ #endif #ifndef TYPE -# define TYPE(__proc) .type __proc, @function; +# ifdef __clang__ +# define TYPE(__proc) // .type not supported +# else +# define TYPE(__proc) .type __proc, @function; +#endif +#endif + +#ifndef PROC_NAME +# ifdef __MACH__ +# define PROC_NAME(__proc) _ ## __proc +# else +# define PROC_NAME(__proc) __proc +# endif #endif #define FUNC(__proc) \ - .global __proc; \ + .global PROC_NAME(__proc); \ .align 2; \ TYPE(__proc) \ ENT(__proc) \ -__proc: \ +PROC_NAME(__proc): \ SETUP_FRAME(__proc) #ifdef __clang__ #define END(__proc)