mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-28 04:00:06 +08:00
Add -ba option for bounds_checking
This commit is contained in:
parent
4a2e33d160
commit
75145ddc1a
5
libtcc.c
5
libtcc.c
@ -1482,6 +1482,7 @@ enum {
|
||||
TCC_OPTION_bench,
|
||||
TCC_OPTION_bt,
|
||||
TCC_OPTION_b,
|
||||
TCC_OPTION_ba,
|
||||
TCC_OPTION_g,
|
||||
TCC_OPTION_c,
|
||||
TCC_OPTION_dumpversion,
|
||||
@ -1544,6 +1545,7 @@ static const TCCOption tcc_options[] = {
|
||||
#endif
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
{ "b", TCC_OPTION_b, 0 },
|
||||
{ "ba", TCC_OPTION_ba, 0 },
|
||||
#endif
|
||||
{ "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||
{ "c", TCC_OPTION_c, 0 },
|
||||
@ -1800,6 +1802,9 @@ reparse:
|
||||
s->do_bounds_check = 1;
|
||||
s->do_debug = 1;
|
||||
break;
|
||||
case TCC_OPTION_ba:
|
||||
s->do_bounds_check_addres = 1;
|
||||
break;
|
||||
#endif
|
||||
case TCC_OPTION_g:
|
||||
s->do_debug = 1;
|
||||
|
@ -368,6 +368,9 @@ Try to continue in case of a bound checking error.
|
||||
|
||||
Note: @option{-b} is only available on i386 (linux and windows) and x86_64 (linux and windows) when using libtcc for the moment.
|
||||
|
||||
@item -ba
|
||||
Generate address checking tests when using @option{-b}. This will be a lot slower but finds more errors.
|
||||
|
||||
@item -bt N
|
||||
Display N callers in stack traces. This is useful with @option{-g} or
|
||||
@option{-b}.
|
||||
|
1
tcc.c
1
tcc.c
@ -59,6 +59,7 @@ static const char help[] =
|
||||
" -g generate runtime debug info\n"
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
" -b compile with built-in memory and bounds checker (implies -g)\n"
|
||||
" -ba Enable better addres checking with bounds checker\n"
|
||||
#endif
|
||||
#ifdef CONFIG_TCC_BACKTRACE
|
||||
" -bt N show N callers in stack traces\n"
|
||||
|
1
tcc.h
1
tcc.h
@ -720,6 +720,7 @@ struct TCCState {
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
/* compile with built-in memory and bounds checker */
|
||||
unsigned char do_bounds_check;
|
||||
unsigned char do_bounds_check_addres;
|
||||
#endif
|
||||
#ifdef TCC_TARGET_ARM
|
||||
enum float_abi float_abi; /* float ABI of the generated code*/
|
||||
|
3
tccgen.c
3
tccgen.c
@ -2509,7 +2509,8 @@ redo:
|
||||
*/
|
||||
/* if evaluating constant expression, no code should be
|
||||
generated, so no bound check */
|
||||
if (tcc_state->do_bounds_check && !const_wanted && !nocode_wanted) {
|
||||
if (tcc_state->do_bounds_check && tcc_state->do_bounds_check_addres
|
||||
&& !const_wanted && !nocode_wanted) {
|
||||
/* if bounded pointers, we generate a special code to
|
||||
test bounds */
|
||||
if (op == '-') {
|
||||
|
Loading…
Reference in New Issue
Block a user