History

Add -ba option for bounds_checking

herman ten brugge committed 6 years ago

Commit 75145dd1 parent 4a2e33d5 files · +12 −1Browse files

Unified · Split

5 files
  1. libtcc.c +5 −0
  2. tcc-doc.texi +3 −0
  3. tcc.c +1 −0
  4. tcc.h +1 −0
  5. tccgen.c +2 −1
libtcc.c+5−0
@@ -1482,6 +1482,7 @@ enum { · 1481 unmodified lines
1482 TCC_OPTION_bench,1482 TCC_OPTION_bench,
1483 TCC_OPTION_bt,1483 TCC_OPTION_bt,
1484 TCC_OPTION_b,1484 TCC_OPTION_b,
1485 TCC_OPTION_ba,
1485 TCC_OPTION_g,1486 TCC_OPTION_g,
1486 TCC_OPTION_c,1487 TCC_OPTION_c,
1487 TCC_OPTION_dumpversion,1488 TCC_OPTION_dumpversion,
@@ -1544,6 +1545,7 @@ static const TCCOption tcc_options[] = { · 56 unmodified lines
1544#endif1545#endif
1545#ifdef CONFIG_TCC_BCHECK1546#ifdef CONFIG_TCC_BCHECK
1546 { "b", TCC_OPTION_b, 0 },1547 { "b", TCC_OPTION_b, 0 },
1548 { "ba", TCC_OPTION_ba, 0 },
1547#endif1549#endif
1548 { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1550 { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1549 { "c", TCC_OPTION_c, 0 },1551 { "c", TCC_OPTION_c, 0 },
@@ -1800,6 +1802,9 @@ reparse: · 250 unmodified lines
1800 s->do_bounds_check = 1;1802 s->do_bounds_check = 1;
1801 s->do_debug = 1;1803 s->do_debug = 1;
1802 break;1804 break;
1805 case TCC_OPTION_ba:
1806 s->do_bounds_check_addres = 1;
1807 break;
1803#endif1808#endif
1804 case TCC_OPTION_g:1809 case TCC_OPTION_g:
1805 s->do_debug = 1;1810 s->do_debug = 1;
tcc-doc.texi+3−0
@@ -368,6 +368,9 @@ Try to continue in case of a bound checking error. · 367 unmodified lines
368 368
369Note: @option{-b} is only available on i386 (linux and windows) and x86_64 (linux and windows) when using libtcc for the moment.369Note: @option{-b} is only available on i386 (linux and windows) and x86_64 (linux and windows) when using libtcc for the moment.
370 370
371@item -ba
372Generate address checking tests when using @option{-b}. This will be a lot slower but finds more errors.
373
371@item -bt N374@item -bt N
372Display N callers in stack traces. This is useful with @option{-g} or375Display N callers in stack traces. This is useful with @option{-g} or
373@option{-b}.376@option{-b}.
tcc.c+1−0
@@ -59,6 +59,7 @@ static const char help[] = · 58 unmodified lines
59 " -g generate runtime debug info\n"59 " -g generate runtime debug info\n"
60#ifdef CONFIG_TCC_BCHECK60#ifdef CONFIG_TCC_BCHECK
61 " -b compile with built-in memory and bounds checker (implies -g)\n"61 " -b compile with built-in memory and bounds checker (implies -g)\n"
62 " -ba Enable better addres checking with bounds checker\n"
62#endif63#endif
63#ifdef CONFIG_TCC_BACKTRACE64#ifdef CONFIG_TCC_BACKTRACE
64 " -bt N show N callers in stack traces\n"65 " -bt N show N callers in stack traces\n"
tcc.h+1−0
@@ -720,6 +720,7 @@ struct TCCState { · 719 unmodified lines
720#ifdef CONFIG_TCC_BCHECK720#ifdef CONFIG_TCC_BCHECK
721 /* compile with built-in memory and bounds checker */721 /* compile with built-in memory and bounds checker */
722 unsigned char do_bounds_check;722 unsigned char do_bounds_check;
723 unsigned char do_bounds_check_addres;
723#endif724#endif
724#ifdef TCC_TARGET_ARM725#ifdef TCC_TARGET_ARM
725 enum float_abi float_abi; /* float ABI of the generated code*/726 enum float_abi float_abi; /* float ABI of the generated code*/
tccgen.c+2−1
@@ -2509,7 +2509,8 @@ redo: · 2508 unmodified lines
2509 */2509 */
2510 /* if evaluating constant expression, no code should be2510 /* if evaluating constant expression, no code should be
2511 generated, so no bound check */2511 generated, so no bound check */
2512 if (tcc_state->do_bounds_check && !const_wanted && !nocode_wanted) {2512 if (tcc_state->do_bounds_check && tcc_state->do_bounds_check_addres
2513 && !const_wanted && !nocode_wanted) {
2513 /* if bounded pointers, we generate a special code to2514 /* if bounded pointers, we generate a special code to
2514 test bounds */2515 test bounds */
2515 if (op == '-') {2516 if (op == '-') {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t