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
14821482 TCC_OPTION_bench,
14831483 TCC_OPTION_bt,
14841484 TCC_OPTION_b,
1485+ TCC_OPTION_ba,
14851486 TCC_OPTION_g,
14861487 TCC_OPTION_c,
14871488 TCC_OPTION_dumpversion,
@@ -1544,6 +1545,7 @@ static const TCCOption tcc_options[] = { · 56 unmodified lines
15441545 #endif
15451546 #ifdef CONFIG_TCC_BCHECK
15461547 { "b", TCC_OPTION_b, 0 },
1548+ { "ba", TCC_OPTION_ba, 0 },
15471549 #endif
15481550 { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15491551 { "c", TCC_OPTION_c, 0 },
@@ -1800,6 +1802,9 @@ reparse: · 250 unmodified lines
18001802 s->do_bounds_check = 1;
18011803 s->do_debug = 1;
18021804 break;
1805+ case TCC_OPTION_ba:
1806+ s->do_bounds_check_addres = 1;
1807+ break;
18031808 #endif
18041809 case TCC_OPTION_g:
18051810 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
368368
369369 Note: @option{-b} is only available on i386 (linux and windows) and x86_64 (linux and windows) when using libtcc for the moment.
370370
371+@item -ba
372+Generate address checking tests when using @option{-b}. This will be a lot slower but finds more errors.
373+
371374 @item -bt N
372375 Display N callers in stack traces. This is useful with @option{-g} or
373376 @option{-b}.
tcc.c+1−0
@@ -59,6 +59,7 @@ static const char help[] = · 58 unmodified lines
5959 " -g generate runtime debug info\n"
6060 #ifdef CONFIG_TCC_BCHECK
6161 " -b compile with built-in memory and bounds checker (implies -g)\n"
62+ " -ba Enable better addres checking with bounds checker\n"
6263 #endif
6364 #ifdef CONFIG_TCC_BACKTRACE
6465 " -bt N show N callers in stack traces\n"
tcc.h+1−0
@@ -720,6 +720,7 @@ struct TCCState { · 719 unmodified lines
720720 #ifdef CONFIG_TCC_BCHECK
721721 /* compile with built-in memory and bounds checker */
722722 unsigned char do_bounds_check;
723+ unsigned char do_bounds_check_addres;
723724 #endif
724725 #ifdef TCC_TARGET_ARM
725726 enum float_abi float_abi; /* float ABI of the generated code*/
tccgen.c+2−1
@@ -2509,7 +2509,8 @@ redo: · 2508 unmodified lines
25092509 */
25102510 /* if evaluating constant expression, no code should be
25112511 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) {
25132514 /* if bounded pointers, we generate a special code to
25142515 test bounds */
25152516 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