From 559675b90acec03b67ed3f2cece1940f00e44c49 Mon Sep 17 00:00:00 2001 From: seyko Date: Fri, 10 Apr 2015 15:17:22 +0300 Subject: a bounds checking code for the ARCH=x86_64 --- tccgen.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index 3b87d0a..9fab0c8 100644 --- a/tccgen.c +++ b/tccgen.c @@ -708,7 +708,7 @@ static void gbound(void) lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL); /* must save type because we must set it to int to get pointer */ type1 = vtop->type; - vtop->type.t = VT_INT; + vtop->type.t = VT_PTR; gaddrof(); vpushi(0); gen_bounded_ptr_add(); @@ -1752,7 +1752,22 @@ ST_FUNC void gen_op(int op) #endif } gen_op('*'); -#ifdef CONFIG_TCC_BCHECK +#if 0 +/* #ifdef CONFIG_TCC_BCHECK + The main reason to removing this code: + #include + int main () + { + int v[10]; + int i = 10; + int j = 9; + fprintf(stderr, "v+i-j = %p\n", v+i-j); + fprintf(stderr, "v+(i-j) = %p\n", v+(i-j)); + } + When this code is on. then the output looks like + v+i-j = 0xfffffffe + v+(i-j) = 0xbff84000 + */ /* if evaluating constant expression, no code should be generated, so no bound check */ if (tcc_state->do_bounds_check && !const_wanted) { -- cgit v1.3.1