2015-04-10 20:17:22 +08:00
|
|
|
/* ---------------------------------------------- */
|
2021-03-30 17:25:58 +08:00
|
|
|
/* alloca-bt.S */
|
2015-04-10 20:17:22 +08:00
|
|
|
|
2020-06-27 23:15:06 +08:00
|
|
|
#ifdef __leading_underscore
|
|
|
|
# define _(s) _##s
|
|
|
|
#else
|
|
|
|
# define _(s) s
|
2020-05-22 12:29:18 +08:00
|
|
|
#endif
|
|
|
|
|
2021-03-30 17:25:58 +08:00
|
|
|
/* ---------------------------------------------- */
|
|
|
|
#if defined __i386__
|
|
|
|
|
|
|
|
.globl _(__bound_alloca)
|
|
|
|
_(__bound_alloca):
|
|
|
|
pop %edx
|
|
|
|
pop %eax
|
|
|
|
mov %eax, %ecx
|
|
|
|
add $3+1,%eax
|
|
|
|
and $-4,%eax
|
|
|
|
jz p6
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
p4:
|
|
|
|
cmp $4096,%eax
|
|
|
|
jbe p5
|
|
|
|
test %eax,-4096(%esp)
|
|
|
|
sub $4096,%esp
|
|
|
|
sub $4096,%eax
|
|
|
|
jmp p4
|
|
|
|
|
|
|
|
p5:
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sub %eax,%esp
|
|
|
|
mov %esp,%eax
|
|
|
|
|
|
|
|
push %edx
|
|
|
|
push %eax
|
|
|
|
push %ecx
|
|
|
|
push %eax
|
|
|
|
call _(__bound_new_region)
|
|
|
|
add $8, %esp
|
|
|
|
pop %eax
|
|
|
|
pop %edx
|
|
|
|
|
|
|
|
p6:
|
|
|
|
push %edx
|
|
|
|
push %edx
|
|
|
|
ret
|
|
|
|
|
|
|
|
/* ---------------------------------------------- */
|
|
|
|
#elif defined __x86_64__
|
|
|
|
|
2020-06-27 23:15:06 +08:00
|
|
|
.globl _(__bound_alloca)
|
|
|
|
_(__bound_alloca):
|
2017-07-24 03:24:11 +08:00
|
|
|
#ifdef _WIN32
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 22:45:45 +08:00
|
|
|
inc %rcx # add one extra to separate regions
|
2020-06-27 23:15:06 +08:00
|
|
|
jmp _(alloca)
|
|
|
|
.globl _(__bound_alloca_nr)
|
|
|
|
_(__bound_alloca_nr):
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 22:45:45 +08:00
|
|
|
dec %rcx
|
2019-12-11 21:06:15 +08:00
|
|
|
push %rax
|
|
|
|
mov %rcx,%rdx
|
|
|
|
mov %rax,%rcx
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 22:45:45 +08:00
|
|
|
sub $32,%rsp
|
2020-06-27 23:15:06 +08:00
|
|
|
call _(__bound_new_region)
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 22:45:45 +08:00
|
|
|
add $32,%rsp
|
2019-12-11 21:06:15 +08:00
|
|
|
pop %rax
|
2015-04-10 20:17:22 +08:00
|
|
|
ret
|
|
|
|
#else
|
|
|
|
pop %rdx
|
|
|
|
mov %rdi,%rax
|
2016-10-02 02:47:36 +08:00
|
|
|
mov %rax,%rsi # size, a second parm to the __bound_new_region
|
2015-04-10 20:17:22 +08:00
|
|
|
|
bcheck cleanup
- revert Makefiles to state before last bcheck additions
Instead, just load bcheck.o explicitly if that is
what is wanted.
- move tcc_add_bcheck() to the <target>-link.c files and
remove revently added arguments. This function is to
support tccelf.c with linking, not for tccgen.c to
support compilation.
- remove -ba option: It said:
"-ba Enable better address checking with bounds checker"
Okay, if it is better then to have it is not an option.
- remove va_copy. It is C99 and we try to stay C89 in tinycc
when possible. For example, MS compilers do not have va_copy.
- win64: revert any 'fixes' to alloca
It was correct as it was before, except for bound_checking
where it was not implemented. This should now work too.
- remove parasitic filename:linenum features
Such feature is already present with rt_printline in
tccrun.c. If it doesn't work it can be fixed.
- revert changes to gen_bounded_ptr_add()
gen_bounded_ptr_add() was working as it should before
(mostly). For the sake of simplicity I switched it to
CDECL. Anyway, FASTCALL means SLOWCALL with tinycc.
In exchange you get one addition which is required for
bounds_cnecking function arguments. The important thing
is to check them *BEFORE* they are loaded into registers.
New function gbound_args() does that.
In any case, code instrumentation with the bounds-check
functions as such now seems to work flawlessly again,
which means when they are inserted as NOPs, any code that
tcc can compile, seems to behave just the same as without
them.
What these functions then do when fully enabled, is a
differnt story. I did not touch this.
2019-12-12 22:45:45 +08:00
|
|
|
add $15 + 1,%rax # add one extra to separate regions
|
2015-04-10 20:17:22 +08:00
|
|
|
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
|
2020-06-27 23:15:06 +08:00
|
|
|
call _(__bound_new_region)
|
2015-04-10 20:17:22 +08:00
|
|
|
pop %rax
|
|
|
|
pop %rdx
|
|
|
|
|
|
|
|
p3:
|
|
|
|
push %rdx
|
|
|
|
ret
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ---------------------------------------------- */
|
2021-03-30 17:25:58 +08:00
|
|
|
#endif
|