mirror of
https://github.com/TinyCC/tinycc.git
synced 2025-11-16 12:34:45 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user