tinycc/lib/alloca86_64-bt.S
Michael Matz fbfe6209be macos: Fix asm-c-connect-test
via some heavy-handed hackery in the ASM symbol handling in case
C symbols get a leading underscore (but ASM symbols do not).
But this is now like clang and GCC on Darwin work: asm symbols are
undecorated, C symbols get a _ prepended, so to connect both some
trickery is involved for the ASM symbols that don't have a _ prepended.
They must be included in the C symbol table (because that's what we use
to lookup also ASM labels), but they also must not disturb the normal
C symbol (which don't have the _ prepended), so they need some mangling.

A bit unsatisfying, but well.  So, add asm-c-connect-test to the working
ones for Darwin as well.
2020-06-20 22:17:08 +02:00

53 lines
1.1 KiB
ArmAsm

/* ---------------------------------------------- */
/* alloca86_64.S */
#ifdef __APPLE__
#define __bound_alloca ___bound_alloca
#define __bound_alloca_nr ___bound_alloca_nr
#define __bound_new_region ___bound_new_region
#endif
.globl __bound_alloca
__bound_alloca:
#ifdef _WIN32
inc %rcx # add one extra to separate regions
jmp alloca
.globl __bound_alloca_nr
__bound_alloca_nr:
dec %rcx
push %rax
mov %rcx,%rdx
mov %rax,%rcx
sub $32,%rsp
call __bound_new_region
add $32,%rsp
pop %rax
ret
#else
pop %rdx
mov %rdi,%rax
mov %rax,%rsi # size, a second parm to the __bound_new_region
add $15 + 1,%rax # add one extra to separate regions
and $-16,%rax
jz p3
sub %rax,%rsp
mov %rsp,%rdi # pointer, a first parm to the __bound_new_region
mov %rsp,%rax
push %rdx
push %rax
call __bound_new_region
pop %rax
pop %rdx
p3:
push %rdx
ret
#endif
/* ---------------------------------------------- */