mirror of
https://github.com/frida/tinycc
synced 2024-11-30 11:33:10 +03:00
6a4f3cf127
tested on win32/64 to pass the tests when enabled - libtcc.c : let tcc define __leading_underscore if enabled tcc_add_symbol() : add _ automatically - tccelf.c : remove tcc_get_symbol_err(), find_c_sym() currently symbol length is limited to 256 in several places, so we can use a fixed local buffer for now as well. - win32/lib/crtinit.c : new file for init/fini - lib/*.S, tests7* : use __leading_underscore - bt-log.c: this file wont work relibaly if compiled with gcc
74 lines
1.7 KiB
ArmAsm
74 lines
1.7 KiB
ArmAsm
/* ---------------------------------------------- */
|
|
/* chkstk86.s */
|
|
|
|
#ifdef __leading_underscore
|
|
# define _(s) _##s
|
|
#else
|
|
# define _(s) s
|
|
#endif
|
|
|
|
/* ---------------------------------------------- */
|
|
#ifndef __x86_64__
|
|
/* ---------------------------------------------- */
|
|
|
|
.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
|
|
/* ---------------------------------------------- */
|
|
|
|
.globl _(__chkstk)
|
|
_(__chkstk):
|
|
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
|
|
P0:
|
|
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)
|
|
|
|
/* ---------------------------------------------- */
|
|
/* setjmp/longjmp support */
|
|
|
|
.globl _(tinyc_getbp)
|
|
_(tinyc_getbp):
|
|
mov %rbp,%rax
|
|
ret
|
|
|
|
/* ---------------------------------------------- */
|
|
#endif
|
|
/* ---------------------------------------------- */
|
|
|
|
|