diff options
| author | grischka <grischka> | 2009-12-19 22:22:43 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2009-12-19 22:22:43 +0100 |
| commit | 7fa712e00c5221d9373e8f8fa073e9e6fa064da1 (patch) | |
| tree | 21c5acbfcb4ddaa6d61d30fe79cfaece3ff7b5d9 /tccgen.c | |
| parent | 8bbde91f62291cb0383c2406ae6123be903c944b (diff) | |
| download | tinycc-7fa712e00c5221d9373e8f8fa073e9e6fa064da1.tar.gz tinycc-7fa712e00c5221d9373e8f8fa073e9e6fa064da1.tar.bz2 | |
win32: enable bounds checker & exception handler
exception handler borrowed from k1w1. Thanks.
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -2911,8 +2911,10 @@ static void indir(void) && (vtop->type.t & VT_BTYPE) != VT_FUNC) { vtop->r |= lvalue_type(vtop->type.t); /* if bound checking, the referenced pointer must be checked */ +#ifdef CONFIG_TCC_BCHECK if (tcc_state->do_bounds_check) vtop->r |= VT_MUSTBOUND; +#endif } } @@ -3328,9 +3330,11 @@ static void unary(void) /* an array is never an lvalue */ if (!(vtop->type.t & VT_ARRAY)) { vtop->r |= lvalue_type(vtop->type.t); +#ifdef CONFIG_TCC_BCHECK /* if bound checking, the referenced pointer must be checked */ if (tcc_state->do_bounds_check) vtop->r |= VT_MUSTBOUND; +#endif } next(); } else if (tok == '[') { @@ -4702,10 +4706,13 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, } if ((r & VT_VALMASK) == VT_LOCAL) { sec = NULL; +#ifdef CONFIG_TCC_BCHECK if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) loc--; +#endif loc = (loc - size) & -align; addr = loc; +#ifdef CONFIG_TCC_BCHECK /* handles bounds */ /* XXX: currently, since we do only one pass, we cannot track '&' operators, so we add only arrays */ @@ -4718,6 +4725,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, bounds_ptr[0] = addr; bounds_ptr[1] = size; } +#endif if (v) { /* local variable */ sym_push(v, type, r, addr); @@ -4774,9 +4782,11 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, /* very important to increment global pointer at this time because initializers themselves can create new initializers */ data_offset += size; +#ifdef CONFIG_TCC_BCHECK /* add padding if bound check */ if (tcc_state->do_bounds_check) data_offset++; +#endif sec->data_offset = data_offset; /* allocate section space to put the data */ if (sec->sh_type != SHT_NOBITS && @@ -4813,7 +4823,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, vsetc(type, VT_CONST | VT_SYM, &cval); vtop->sym = sym; } - +#ifdef CONFIG_TCC_BCHECK /* handles bounds now because the symbol must be defined before for the relocation */ if (tcc_state->do_bounds_check) { @@ -4825,6 +4835,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, bounds_ptr[0] = 0; /* relocated */ bounds_ptr[1] = size; } +#endif } if (has_init) { decl_initializer(type, sec, addr, 1, 0); |
