2009-07-19 00:06:54 +04:00
|
|
|
/* ---------------------------------------------- */
|
|
|
|
/* chkstk86.s */
|
|
|
|
|
|
|
|
/* ---------------------------------------------- */
|
2017-07-23 22:24:11 +03:00
|
|
|
#ifndef __x86_64__
|
2009-07-19 00:06:54 +04:00
|
|
|
/* ---------------------------------------------- */
|
|
|
|
|
|
|
|
.globl __chkstk
|
|
|
|
|
|
|
|
__chkstk:
|
|
|
|
xchg (%esp),%ebp /* store ebp, get ret.addr */
|
|
|
|
push %ebp /* push ret.addr */
|
|
|
|
lea 4(%esp),%ebp /* setup frame ptr */
|
|
|
|
push %ecx /* save ecx */
|
|
|
|
mov %ebp,%ecx
|
|
|
|
P0:
|
|
|
|
sub $4096,%ecx
|
|
|
|
test %eax,(%ecx)
|
|
|
|
sub $4096,%eax
|
|
|
|
cmp $4096,%eax
|
|
|
|
jge P0
|
|
|
|
sub %eax,%ecx
|
|
|
|
test %eax,(%ecx)
|
|
|
|
|
|
|
|
mov %esp,%eax
|
|
|
|
mov %ecx,%esp
|
|
|
|
mov (%eax),%ecx /* restore ecx */
|
|
|
|
jmp *4(%eax)
|
|
|
|
|
|
|
|
/* ---------------------------------------------- */
|
|
|
|
#else
|
|
|
|
/* ---------------------------------------------- */
|
2005-04-17 17:10:37 +04:00
|
|
|
|
|
|
|
.globl __chkstk
|
|
|
|
|
|
|
|
__chkstk:
|
2009-07-19 00:06:54 +04:00
|
|
|
xchg (%rsp),%rbp /* store ebp, get ret.addr */
|
|
|
|
push %rbp /* push ret.addr */
|
|
|
|
lea 8(%rsp),%rbp /* setup frame ptr */
|
|
|
|
push %rcx /* save ecx */
|
|
|
|
mov %rbp,%rcx
|
|
|
|
movslq %eax,%rax
|
2005-04-17 17:10:37 +04:00
|
|
|
P0:
|
2009-07-19 00:06:54 +04:00
|
|
|
sub $4096,%rcx
|
|
|
|
test %rax,(%rcx)
|
|
|
|
sub $4096,%rax
|
|
|
|
cmp $4096,%rax
|
|
|
|
jge P0
|
|
|
|
sub %rax,%rcx
|
|
|
|
test %rax,(%rcx)
|
|
|
|
|
|
|
|
mov %rsp,%rax
|
|
|
|
mov %rcx,%rsp
|
|
|
|
mov (%rax),%rcx /* restore ecx */
|
|
|
|
jmp *8(%rax)
|
2005-04-17 17:10:37 +04:00
|
|
|
|
2009-12-17 20:44:58 +03:00
|
|
|
/* ---------------------------------------------- */
|
2009-12-20 00:40:28 +03:00
|
|
|
/* setjmp/longjmp support */
|
2009-12-17 20:44:58 +03:00
|
|
|
|
2009-12-20 00:40:28 +03:00
|
|
|
.globl tinyc_getbp
|
|
|
|
tinyc_getbp:
|
|
|
|
mov %rbp,%rax
|
2009-12-17 20:44:58 +03:00
|
|
|
ret
|
|
|
|
|
2009-07-19 00:06:54 +04:00
|
|
|
/* ---------------------------------------------- */
|
|
|
|
#endif
|
|
|
|
/* ---------------------------------------------- */
|
2010-10-19 15:15:06 +04:00
|
|
|
|
|
|
|
|