diff --git a/lib/alloca86_64-bt.S b/lib/alloca86_64-bt.S index 4cbad90f..15bca090 100644 --- a/lib/alloca86_64-bt.S +++ b/lib/alloca86_64-bt.S @@ -5,7 +5,6 @@ __bound_alloca: #ifdef _WIN32 - # bound checking is not implemented pop %rdx mov %rcx,%rax add $15,%rax @@ -23,8 +22,18 @@ p2: sub %rax,%rsp mov %rsp,%rax - add $32,%rax + push %rdx + push %rax + mov %rcx,%rdx + mov %rax,%rcx + sub $20,%rsp + call __bound_new_region + add $20,%rsp + pop %rax + pop %rdx + + add $32,%rax p3: push %rdx ret diff --git a/x86_64-gen.c b/x86_64-gen.c index 741ae0ff..e5d99fa7 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -1025,7 +1025,7 @@ void gfunc_call(int nb_args) if ((vtop->r & VT_SYM) && vtop->sym->v == TOK_alloca) { /* need to add the "func_scratch" area after alloca */ - o(0x48); func_alloca = oad(0x05, func_alloca); /* sub $NN, %rax */ + o(0x48); func_alloca = oad(0x2d, func_alloca); /* sub $NN, %rax */ } /* other compilers don't clear the upper bits when returning char/short */