Bound checking fixes

tccgen.c:
- Fix 'tcc -b conftest.s'
- Add offset during bound checking for struct return

lib/bcheck.c:
- Check overlap when reusing vla/alloca

arm-gen.c:
arm64-gen.c:
riscv64-gen.c:
lib/alloca86-bt.S:
- add space for vla/alloca during bound checking

tests/tests2/Makefile:
tests/tests2/121_struct_return:
tests/tests2/122_vla_reuse:
- New test cases with bound checking enabled to test vla and struct return
This commit is contained in:
herman ten brugge
2020-10-01 17:09:09 +02:00
parent 352e1d0fc4
commit afc0917f88
11 changed files with 104 additions and 4 deletions

View File

@@ -1327,6 +1327,11 @@ ST_FUNC void gen_vla_alloc(CType *type, int align)
vpushv(vtop);
#endif
rr = ireg(gv(RC_INT));
#if defined(CONFIG_TCC_BCHECK)
if (tcc_state->do_bounds_check)
EI(0x13, 0, rr, rr, 15+1); // addi RR, RR, 15+1
else
#endif
EI(0x13, 0, rr, rr, 15); // addi RR, RR, 15
EI(0x13, 7, rr, rr, -16); // andi, RR, RR, -16
ER(0x33, 0, 2, 2, rr, 0x20); // sub sp, sp, rr